Android 网格布局
示例
顾名思义,GridLayout是用于在网格中排列View的布局。GridLayout将自身分为列和行。如下面的示例所示,列和/或行的数量由属性columnCount和指定rowCount。将视图添加到此布局会将第一个视图添加到第一列,将第二个视图添加到第二列,并且将第三个视图添加到第二行的第一列。
<?xml version="1.0" encoding="utf-8"?>
<GridLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:columnCount="2"
android:rowCount="2">
<TextView
android:layout_width="@dimen/fixed"
android:layout_height="wrap_content"
android:text="@string/first"
android:background="@color/colorPrimary"
android:layout_margin="@dimen/default_margin" />
<TextView
android:layout_width="@dimen/fixed"
android:layout_height="wrap_content"
android:text="@string/second"
android:background="@color/colorPrimary"
android:layout_margin="@dimen/default_margin" />
<TextView
android:layout_width="@dimen/fixed"
android:layout_height="wrap_content"
android:text="@string/third"
android:background="@color/colorPrimary"
android:layout_margin="@dimen/default_margin" />
</GridLayout>热门推荐
6 敏字的祝福语简短
10 海鲜送礼祝福语简短大全
11 新婚祝福语大全简短经典
12 老师节祝福语的简短
13 2026新年祝福语简短语
14 发给导师的祝福语简短
15 祝福语生日男朋友简短
16 年底老板祝福语简短的
17 老师新婚快乐祝福语简短
18 同事调动的祝福语简短