Android XML 布局基础(八)帧布局 - GridLayout

| android:layout_rowSpan="数字" | 占用一列的几个行位置 |

| android:layout_columnWeight="数字" | 该控件的列权重,与 android:layout_weight 类似,例如有 GridLayout 上两列,都设置 android:layout_columnWeight = "1",则两列各占 GridLayout 宽度的一半 |

| android:layout_rowWeight="数字" | 跟 layout_columnWeight 同理 |

二、案例


<?xml versi on="1.0" encoding="utf-8"?>

<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"

xmlns:app="http://schemas.android.com/apk/res-auto"

xmlns:tools="http://schemas.android.com/tools"

android:layout_width="match_parent"

android:layout_height="match_parent"

tools:context=".MainActivity">

<GridLayout

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:columnCount="4"

android:rowCount="6"

tools:ignore="MissingConstraints">

<View

android:layout_width="80dp"

android:layout_height="80dp"

android:background="#ffc"/>

<View

android:layout_width="80dp"

android:layout_height="80dp"

android:background="#fcf"/>

<View

android:layout_width="80dp"

android:layout_height="80dp"

android:background="#cff"/>

<View

android:layout_width="80dp"

android:layout_height="80dp"

android:background="#ccc"/>

<View

android:layout_rowSpan="2"

android:layout_width="80dp"

android:layout_height="160dp"

android:background="#ddd"/>

<View

android:layout_rowSpan="2"

android:layout_width="80dp"

android:layout_height="160dp"

android:background="#cdc"/>

<View

android:layout_columnSpan="2"

android:layout_width="160dp"

android:layout_height="80dp"

android:background="#f88"/>

<View

android:layout_columnSpan="2"

相关推荐
萧雾宇1 小时前
Android Compose打造仿现实逼真的烟花特效
android·flutter·kotlin
翻滚丷大头鱼2 小时前
android 性能优化—ANR
android·性能优化
翻滚丷大头鱼2 小时前
android 性能优化—内存泄漏,内存溢出OOM
android·性能优化
拜无忧2 小时前
【教程】flutter常用知识点总结-针对小白
android·flutter·android studio
拜无忧3 小时前
【教程】Flutter 高性能项目架构创建指南:从入门到高性能架构
android·flutter·android studio
用户2018792831673 小时前
故事:公司的 "私人储物柜" 系统(ThreadLocalMap)
android·java
CYRUS_STUDIO3 小时前
如何防止 so 文件被轻松逆向?精准控制符号导出 + JNI 动态注册
android·c++·安全
yinmaisoft3 小时前
当低代码遇上AI,有趣,实在有趣
android·人工智能·低代码·开发工具·rxjava
如此风景4 小时前
Compose Modifier 修饰符介绍
android
纽马约4 小时前
Android BaseQuickAdapter的使用
android