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 Studio开发 SharedPreferences 详解
android·ide·android studio
青春给了狗1 小时前
Android 14 修改侧滑手势动画效果
android
CYRUS STUDIO1 小时前
Android APP 热修复原理
android·app·frida·hotfix·热修复
火柴就是我2 小时前
首次使用Android Studio时,http proxy,gradle问题解决
android
limingade2 小时前
手机打电话时电脑坐席同时收听对方说话并插入IVR预录声音片段
android·智能手机·电脑·蓝牙电话·电脑打电话
浩浩测试一下3 小时前
计算机网络中的DHCP是什么呀? 详情解答
android·网络·计算机网络·安全·web安全·网络安全·安全架构
青春给了狗4 小时前
Android 14 系统统一修改app启动时图标大小和圆角
android
pengyu5 小时前
【Flutter 状态管理 - 柒】 | InheritedWidget:藏在组件树里的"魔法"✨
android·flutter·dart
居然是阿宋6 小时前
Kotlin高阶函数 vs Lambda表达式:关键区别与协作关系
android·开发语言·kotlin
凉、介7 小时前
PCI 总线学习笔记(五)
android·linux·笔记·学习·pcie·pci