创建网格布局。 [英] Create gridlayout.
本文介绍了创建网格布局。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要这样的创建布局:
,我试图做到这一点使用网格布局,但我无法找到正确的方法。任何人都可以请给我一些指导?谢谢!
I need to create a layout like this: , I'm trying to do this using gridlayout, but it I cannot find the correct method. Can anyone please give me some guidance? Thanks!
推荐答案
我想这是最简单的方法是结合的横向的和的垂直的 LinearLayouts
,不同的权重
设置为它的子视图。
I guess that the most straightforward way is combining horizontal and vertical LinearLayouts
, setting different weights
to its subviews.
这code片段可能是一个起点.-
This code snippet could be a start point.-
<LinearLayout
android:layout_width="match_parent"
android:layout_height="100dp" >
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@color/green"
android:layout_margin="5dp" >
</RelativeLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_margin="5dp"
android:background="@color/orange" >
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_margin="5dp"
android:background="@color/green" >
</RelativeLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="100dp" >
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_margin="5dp"
android:layout_weight="0.5"
android:background="@color/orange" >
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_margin="5dp"
android:layout_weight="1"
android:background="@color/black" >
</RelativeLayout>
</LinearLayout>
这会导致这样的布局.-
Which results in a layout like this.-
PinterestListView 看起来很有希望为好。
PinterestListView looks promising as well.
这篇关于创建网格布局。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文