Assign width to half available screen width declaratively
If your widget is a Button: <LinearLayout android:layout_width=”fill_parent” android:layout_height=”wrap_content” android:weightSum=”2″ android:orientation=”horizontal”> <Button android:layout_width=”0dp” android:layout_height=”wrap_content” android:layout_weight=”1″ android:text=”somebutton”/> <TextView android:layout_width=”0dp” android:layout_height=”wrap_content” android:layout_weight=”1″/> </LinearLayout> I’m assuming you want your widget to take up one half, and another widget to take up the other half. The trick is using a LinearLayout, setting layout_width=”fill_parent” on both widgets, and setting layout_weight … Read more