我有幾個垂直列出的按鈕,我需要它們都具有相同的寬度,而且還要顯示裏面的所有文本。如何在Android佈局中實現按鈕的自動寬度
基本上我需要寬度作爲最大的包裝寬度。
希望我解釋清楚。
現在...我已經有一個佈局,正在我的三星Galaxy S2(4.1.2),但在朋友的手機 - 三星GT-N7100(note2)和Android 4.4.2 - 它不工作 - 某些文本不會顯示在按鈕中。
這是我的佈局:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:text="word"
android:layout_width="wrap_content"
android:layout_height="48dp"
android:textSize="30sp"
android:gravity="center"
android:layout_centerHorizontal="true"
android:id="@+id/word"/>
<TextView
android:text="14/36\nM: 1"
android:layout_width="fill_parent"
android:layout_height="80dp"
android:id="@+id/score"
android:layout_toRightOf="@+id/word"
android:gravity="right|center"
android:paddingRight="10dp"/>
<LinearLayout
android:layout_centerInParent="true"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/adapter">
<Button
android:text="1"
android:layout_width="match_parent"
android:layout_height="48dp"
android:id="@+id/opt1"/>
<Button
android:text="2"
android:layout_width="match_parent"
android:layout_height="48dp"
android:id="@+id/opt2" />
<Button
android:text="3"
android:layout_width="match_parent"
android:layout_height="48dp"
android:id="@+id/opt3" />
<Button
android:text="4"
android:layout_width="match_parent"
android:layout_height="48dp"
android:id="@+id/opt4" />
<Button
android:text="5"
android:layout_width="match_parent"
android:layout_height="48dp"
android:id="@+id/opt5" />
</LinearLayout>
<Button
android:text="Next"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_alignParentBottom="true"
android:id="@+id/next"/>
</RelativeLayout>
什麼是錯的出現?你可以發佈它的截圖嗎? –