how to set layout's width to be 80% of the screen's full width?
like the question indicated, how can a simpleton like me could implement something like that via xml? if not, programmatically thanks.
update:
thanks for your help, now here is the result of my layout
<TableLayout android:layout_width="match_parent" android:layout_gravity="center"
android:layout_weight="10" android:layout_height="wrap_content">
<TableRow android:layout_weight="10">
<TextView android:id="@+id/labelVaccinesImmuDialog"
android:layout_weight="0"
android:layout_width="match_parent"
android:text="@string/vaccine_spinner_label" android:layout_gravity="center_vertical" />
<Spinner android:id="@+id/spinnerVaccinesImmuDialog"
android:layout_weight="8"
android:layout_width="0dp"
android:prompt="@string/vaccine_spinner_label" android:layout_height="44dp"/>
</TableRow>
<TableRow android:layout_weight="10">
<Button android:id="@+id/buttonDatePickerImmuDialog"
android:text="@string/datepicker_button_label"
android:layout_weight="0"
android:layout_width="match_parent"
android:layout_height="44dp"/>
<EditText android:id="@+id/editDateImmuDialog"
android:singleLine="true"
android:layout_weight="8"
android:padding="5px"
android:layout_width="0dp"
android:text="@string/immu_dialog_date_edit" android:layout_height="44dp"/>
</TableRow>
<TableRow android:layout_weight="10">
<TextView android:id="@+id/labelAdverseReactions"
android:text="@string/immu_dialog_adverse_reaction_label"
android:layout_gravity="center_vertical"
android:layout_weight="0"
android:layout_width="match_parent"/>
<Spinner android:id="@+id/spinnerAdverseReactionsImmuDialog"
android:layout_weight="8"
android:padding="5px"
android:layout_width="0dp"
android:text="@string/immu_dialog_adverse_reaction_spinner_label" android:layout_height="44dp"/>
</TableRow>
<Ta开发者_高级运维bleRow android:layout_weight="10">
<TextView android:id="@+id/labelDoctorWhoAdministered"
android:text="@string/immu_dialog_doctor_administered_label"
android:layout_weight="0"
android:layout_gravity="center_vertical" android:layout_width="match_parent"/>
<EditText android:id="@+id/editDoctorWhoAdministeredImmuDialog"
android:singleLine="true"
android:layout_width="0dp"
android:layout_weight="8"
android:padding="5px"
android:text="@string/immu_dialog_doctor_administered_edit" android:layout_height="44dp"/>
</TableRow>
<TableRow android:layout_weight="10">
<Button android:id="@+id/buttonSubmitImmuDialog"
android:layout_weight="0"
android:text="@string/immu_dialog_submit_button" android:layout_height="44dp"/>
<Button android:id="@+id/buttonCancelImmuDialog"
android:layout_weight="8"
android:layout_width="0dp"
android:text="@string/immu_dialog_cancel_button" android:layout_height="44dp"/>
</TableRow>
</TableLayout>
in a linear layout, you could have another object to use up the other 20% then use layout_weight
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:orientation="horizontal">
<LinearLayout android:orientation="horizontal"
android:layout_height="fill_parent" android:layout_width="fill_parent"
android:layout_weight=".2" android:background="#ffaa0000" />
<LinearLayout android:id="@+id/textLayout"
android:orientation="horizontal" android:layout_height="fill_parent"
android:layout_width="fill_parent" android:layout_weight=".8" />
</LinearLayout>
in tablerows
<?xml version="1.0" encoding="utf-8"?>
<TableLayout android:id="@+id/TableLayout01"
android:layout_width="fill_parent" android:layout_height="wrap_content">
<TableRow android:id="@+id/TableRow01" android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView android:text="@+id/TextView01" android:id="@+id/TextView01"
android:layout_width="0dp" android:layout_height="wrap_content"
android:layout_weight="10"></TextView>
<TextView android:text="@+id/TextView01" android:id="@+id/TextView01"
android:layout_width="0dp" android:layout_height="wrap_content"
android:layout_weight="1"></TextView>
</TableRow>
<TableRow android:id="@+id/TableRow01" android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView android:text="@+id/TextView01" android:id="@+id/TextView01"
android:layout_width="0dp" android:layout_height="wrap_content"
android:layout_weight="10"></TextView>
<TextView android:text="@+id/TextView01" android:id="@+id/TextView01"
android:layout_width="0dp" android:layout_height="wrap_content"
android:layout_weight="1"></TextView>
</TableRow>
</TableLayout>
精彩评论