I want to change the width of one fragment in the main operation? perhaps because I cannot find "layoutparams" to change the default value:
public class MainActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); int widthFfragment=300; Display display = getWindowManager().getDefaultDisplay(); Point size = new Point(); display.getSize(size); widthTot = size.x; heightTot = size.y; findViewById(R.id.f1).getLayoutParams().width = widthTot-widthFfragment;
}}
this is the fragment code:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/f1" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#330000" android:gravity="center_horizontal|center_vertical" android:orientation="vertical" > <TextView android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Fragment 1" android:textAppearance="?android:attr/textAppearanceLarge" />
Fragment1.java
public class Fragment1 extends Fragment{ @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
}
thanks
source share