0
在Android中可能會自動調整同一行上的botton寬度而不在佈局文件中寫入指定的寬度?如何自動適應Android中同一行上的bottons寬度?
我問這個問題,因爲用AppInvetor它可能會自動適應bottons的寬度,這就是爲什麼我問你這個問題的原因。
在Android中可能會自動調整同一行上的botton寬度而不在佈局文件中寫入指定的寬度?如何自動適應Android中同一行上的bottons寬度?
我問這個問題,因爲用AppInvetor它可能會自動適應bottons的寬度,這就是爲什麼我問你這個問題的原因。
您可以使用TableLayout來執行此操作。只需添加按鈕TableRow
S和給他們match_parent寬度
的一種方式是一個表:
<TableLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TableRow>
<Button />
<Button />
</TableRow>
<\TableLayout>
替代地,可以執行水平線性佈局和分配權重給每個按鈕爲0的寬度。
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:layout_width="0dp"
android:layout_weight="1" />
<Button
android:layout_width="0dp"
android:layout_weight="1" />
<\LinearLayout>