【问题标题】:Menu Buttons Layout菜单按钮布局
【发布时间】:2013-11-04 07:39:35
【问题描述】:

我想创建一个包含 6 个按钮的菜单,假设在此布局中。谁能帮帮我?

【问题讨论】:

  • 你应该展示你将来尝试过的东西。

标签: android layout menu icons


【解决方案1】:

这将为您提供准确的布局(我在此布局中使用了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

【讨论】:

    【解决方案2】:

    你可以使用&lt;TableLayout&gt; ... &lt;/TableLayout&gt;

    示例:http://www.mkyong.com/android/android-tablelayout-example/

    【讨论】:

      猜你喜欢
      • 2011-08-26
      • 2019-08-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-12-23
      • 1970-01-01
      • 2023-03-06
      • 2018-02-22
      相关资源
      最近更新 更多