The following dialog is unaffected by weight parameters. Could someone explain why?
extensible markup language:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:weightSum="1" android:orientation="horizontal">
<TextView android:id="@+id/dialogtext" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_weight=".3" />
<Button android:id="@+id/dialogbutton"
android:layout_width="0dp" android:layout_weight=".7"
android:layout_height="wrap_content" android:text="Cancel" />
</LinearLayout>
java:
dialog = new Dialog(GameActivity.this);
dialog.setContentView(R.layout.dialog);
TextView textdialog = (TextView) dialog.findViewById(R.id.dialogtext);
textdialog.setText("i dont care what size you want me to be, im comfortable with my body");
button = (Button) dialog.findViewById(R.id.dialogbutton);
button.setOnClickListener(this);
dialog.show();
If I specify the dimensions to a dp, it responds, however.
I suspect you need to make the width of the outer LinearLayout set to match_parent. Otherwise, the LinearLayout will make itself just wide enough to hold its children, which in turn are just wide enough to show themselves. Result being no extra width to distribute with the weights.