我正在尝试制作类似于这个 - Android布局(用户界面),只是我想使第一列的权重为4,第二列的权重为2(还有两行),最后一列的权重为1(还有三行)......问题是它在自己身上弄乱了(我复制并粘贴了答案,并根据我的需求进行了更改,但它一直在混乱中.. =)需要帮助?
[code]
这是结果 -
结果应该看起来像这样 -
需要帮助吗?
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/background_color"
android:orientation="vertical"
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="4"
android:gravity="center_horizontal|center_vertical"
android:orientation="horizontal" >
<TextView
android:id="@+id/textDishes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:text="@string/dishes"
android:textAppearance="?android:attr/textAppearanceLarge" />
<ImageView
android:id="@+id/imageDishes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher" />
</LinearLayout>
<View
android:layout_width="fill_parent"
android:layout_height="@dimen/seperator_size"
android:background="@color/seperator" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="2"
android:measureWithLargestChild="true"
android:orientation="horizontal"
android:weightSum="2" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_horizontal"
android:orientation="vertical" >
<TextView
android:id="@+id/textfood"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/food"
android:textAppearance="?android:attr/textAppearanceLarge" />
<ImageView
android:id="@+id/imagefood"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher" />
</LinearLayout>
<View
android:layout_width="fill_parent"
android:layout_height="@dimen/seperator_size"
android:background="@color/seperator" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_horizontal"
android:orientation="vertical" >
<TextView
android:id="@+id/textMalls"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/malls"
android:textAppearance="?android:attr/textAppearanceLarge" />
<ImageView
android:id="@+id/imageMalls"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher" />
</LinearLayout>
</LinearLayout>
<View
android:layout_width="fill_parent"
android:layout_height="@dimen/seperator_size"
android:background="@color/seperator" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:weightSum="3"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_horizontal"
android:orientation="vertical" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/app_name"
android:textAppearance="?android:attr/textAppearanceLarge" />
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher" />
</LinearLayout>
<View
android:layout_width="fill_parent"
android:layout_height="@dimen/seperator_size"
android:background="@color/seperator" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_horizontal"
android:orientation="vertical" >
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/coupons"
android:textAppearance="?android:attr/textAppearanceLarge" />
<ImageView
android:id="@+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher" />
</LinearLayout>
<View
android:layout_width="fill_parent"
android:layout_height="@dimen/seperator_size"
android:background="@color/seperator" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_horizontal"
android:orientation="vertical" >
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/markets"
android:textAppearance="?android:attr/textAppearanceLarge" />
<ImageView
android:id="@+id/imageView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
[/code]
这是结果 -
![enter image description here](https://istack.dev59.com/P4hhA.webp)
![enter image description here](https://istack.dev59.com/jYzoR.webp)