【发布时间】:2013-11-04 07:39:35
【问题描述】:
我想创建一个包含 6 个按钮的菜单,假设在此布局中。谁能帮帮我?
【问题讨论】:
-
你应该展示你将来尝试过的东西。
我想创建一个包含 6 个按钮的菜单,假设在此布局中。谁能帮帮我?
【问题讨论】:
这将为您提供准确的布局(我在此布局中使用了ImageButtons)
我添加了滚动视图,以便菜单可以在非常小的屏幕上滚动。如果你愿意,你可以删除它。
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dp" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:weightSum="2" >
<ImageButton
android:id="@+id/id1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:layout_weight="1"
android:background="@null"
android:src="@drawable/icon" />
<ImageButton
android:id="@+id/id2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_weight="1"
android:background="@null"
android:src="@drawable/icon" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal"
android:weightSum="2" >
<ImageButton
android:id="@+id/id3"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:layout_weight="1"
android:background="@null"
android:src="@drawable/icon" />
<ImageButton
android:id="@+id/id4"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:layout_weight="1"
android:background="@null"
android:src="@drawable/icon" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal"
android:weightSum="2" >
<ImageButton
android:id="@+id/id5"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_weight="1"
android:background="@null"
android:src="@drawable/icon" />
<ImageButton
android:id="@+id/id6"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_weight="1"
android:background="@null"
android:src="@drawable/icon" />
</LinearLayout>
</LinearLayout>
</ScrollView>
或者你可以使用TableLayout
【讨论】:
你可以使用<TableLayout> ... </TableLayout>
示例:http://www.mkyong.com/android/android-tablelayout-example/
【讨论】: