我想4個按鈕添加到屏幕上,使得它應顯示爲中心:Android中最常用的佈局是什麼?
Button 1 Button 2
Button 3 Button 4
,這是什麼最好的佈局方法?或者我怎樣才能用不同的佈局來做到這一點。 我嘗試了tablelayout,但最終產品在不同的屏幕尺寸上移動了位置。
感謝您的幫助!
我想4個按鈕添加到屏幕上,使得它應顯示爲中心:Android中最常用的佈局是什麼?
Button 1 Button 2
Button 3 Button 4
,這是什麼最好的佈局方法?或者我怎樣才能用不同的佈局來做到這一點。 我嘗試了tablelayout,但最終產品在不同的屏幕尺寸上移動了位置。
感謝您的幫助!
如果使用的是線性佈局然後機器人:比重=「中心」確保了在佈局中的所有小工具是在中心,並且如果使用的是相對佈局然後機器人:layout_centerHorizontal =「真」 機器人: layout_centerVertical =「true」 讓您的小工具保持在中心
謝謝。我來檢查一下。 – Amrit 2013-05-09 08:49:56
線性佈局是最好的。
我用這種按鈕排列的表格佈局。
<TableLayout
android:id="@+id/row1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1" >
<TableRow android:layout_weight="1" >
<Button
android:id="@+id/Button1"
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="1"
android:focusable="false"
android:focusableInTouchMode="false"
android:text="1"
android:textSize="40sp" />
<Button
android:id="@+id/Button2"
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="1"
android:focusable="false"
android:focusableInTouchMode="false"
android:text="2"
android:textSize="40sp" />
</TableRow>
<TableRow android:layout_weight="1" >
<Button
android:id="@+id/Button3"
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="1"
android:focusable="false"
android:focusableInTouchMode="false"
android:text="3"
android:textSize="40sp" />
<Button
android:id="@+id/Button4"
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="1"
android:focusable="false"
android:focusableInTouchMode="false"
android:text="4"
android:textSize="40sp" />
</TableRow>
</TableLayout>
使用相對佈局 – Raghunandan 2013-05-09 08:14:55
誰會爲您做這項調查? – Sameer 2013-05-09 08:15:10
我個人的建議是使用這種設計的所有佈局。它可以通過所有的佈局。當你可以使用所有佈局來完成這個設計時,我希望你對佈局有一個很好的瞭解 – stinepike 2013-05-09 08:17:06