我試過這段代碼,但是這些按鈕上的文字在我的手機中混淆了;雖然它在Nexus 5仿真器中沒有問題....!我怎樣才能把這些4個按鈕一行動態,使他們可以看看在任何屏幕尺寸相同...即使應用在任何屏幕尺寸上運行,如何將這四個按鈕設置爲一行?
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:weightSum="8" >
<Button
android:id="@+id/bback"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="2"
android:text="Back" />
<Button
android:id="@+id/bforward"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="2"
android:text="Forward" />
<Button
android:id="@+id/brefresh"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="2"
android:text="Refresh" />
<Button
android:id="@+id/bclear"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="2"
android:text="Clear History" />
</LinearLayout>
使用width作爲wrap_content可能會解決您的問題。那麼你將不得不去除權重。 – 2015-04-03 08:34:06
但隨後按鈕尺寸會變得不同...... :( – Saurabh 2015-04-03 08:39:22
是否要在任何屏幕尺寸下保持按鈕尺寸相同 – 2015-04-03 08:47:04