android 多行布局,android布局-网格布局

网格布局

自android4.0版本后新增的GridLayout网格布局的一些基本内容

GridLayout布局使用虚细线将布局划分为行,列和单元格,也支持一个控件在行,列上都有交错排列

GridLayout的布局策略简单分为以下三个部分:

与LinearLayout布局一样,也分为水平和垂直两种方式

默认是水平布局,一个控件挨着一个控件从左到右一次排列

通过指定android:columnCount设置列数的属性后,控件会自动换行进行排列

对于GridLayout布局中的子控件,默认按照wrap_content的方式设置其显示,这只需要在GridLayout布局中显式声明即可

GridLayout的布局策略简单分为以下三个部分:

1、若要指定某控件显示在固定的行或列

只需设置该子控件的android:layout_row和android:layout_column属性即可

需要注意:android:layout_row="0"表示从第一行开始

android:layout_column="0"表示从第一列开始

2、设置某控件跨越多行或多列

该子控件的android:layout_rowSpan或者layout_columnSpan属性设置为数值

设置其layout_gravity属性为fill即可

前一个设置表明该控件跨越的行数或列数,后一个设置表明该控件填满所跨越的整行或整列

a4c26d1e5885305701be709a3d33442f.png

http://schemas.android.com/apk/res/android"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:columnCount="5"

android:orientation="horizontal" >

<

Button

android:text="1"

/>

<

Button

android:text="2"

/>

<

Button

android:text="3"

android:layout_row="1"

android:layout_column="1"

android:layout_columnSpan="2"

android:layout_gravity="fill"

/>

<

Button

android:text="4"

android:layout_row="0"

/>

<

Button

android:text="5"

/>

<

Button

android:text="6"

/>

a4c26d1e5885305701be709a3d33442f.png

http://schemas.android.com/apk/res/android"

android:layout_width="match_parent"

android:layout_height="wrap_content

android:columnCount="3">

<

ImageView

android:layout_row="0"

android:layout_column="0"

android:layout_rowSpan="2"

android:src="@drawable/ic_launcher"

/>

<

TextView

android:layout_row="0"

android:layout_column="1"

android:text="设置"

/>

<

TextView

android:layout_row="0"

android:layout_column="2"

android:text="44MB"

android:layout_gravity="right" />

<

TextView

android:layout_row="1"

android:layout_column="1"

android:text="一个文件"

android:layout_gravity="bottom"

/>

<

TextView

android:layout_row="1"

android:layout_column="2"

android:text="15:04"

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值