技术标签: android Android应用开发技术
网格布局是Android 4.0以后引入的一个新的布局.
它和前面所学的TableLayout(表格布局) 有点类似,不过有很多前者没有的东西,也更加好用.
特点:
GridLayout属性:
属性 | 作用 |
---|---|
android:columnCount | 最大列数 |
android:rowCount | 最大行数 |
android:orientation | GridLayout中子元素的布局方向 |
android:alignmentMode | alignBounds:对齐子视图边界 alignMargins :对齐子视距内容,默认值 |
android:columnOrderPreserved | 使列边界显示的顺序和列索引的顺序相同,默认是true |
android:rowOrderPreserved | 使行边界显示的顺序和行索引的顺序相同,默认是true |
android:useDefaultMargins | 没有指定视图的布局参数时使用默认的边距,默认值是false |
子元素属性:
属性 | 作用 |
---|---|
android:layout_column | 指定该单元格在第几列显示 |
android:layout_row | 指定该单元格在第几行显示 |
android:layout_columnSpan | 指定该单元格占据的列数 |
android:layout_rowSpan | 指定该单元格占据的行数 |
android:layout_gravity | 指定该单元格在容器中的位置 |
android:layout_columnWeight | (API21加入)列权重 |
android:layout_rowWeight | (API21加入) 行权重 |
GridLayout在API21时引入了android:layout_columnWeight和android:layout_rowWeight来解决平分问题
使用layout_columnSpan
、layout_rowSpan
时要加上layout_gravity
属性,否则没有效果
activity_main.xml:
<?xml version="1.0" encoding="utf-8"?>
<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:columnCount="4"
android:rowCount="5"
android:orientation="vertical"
tools:context=".MainActivity">
<Button
android:id="@+id/button0"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_row="0"
android:layout_column="0"
android:layout_rowWeight="1"
android:text="Button0" />
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_row="1"
android:layout_column="1"
android:layout_rowWeight="1"
android:text="Button1" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_row="2"
android:layout_column="2"
android:layout_rowWeight="1"
android:text="Button2" />
<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_row="3"
android:layout_column="1"
android:layout_rowWeight="1"
android:text="Button3" />
<Button
android:id="@+id/button4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_row="4"
android:layout_column="0"
android:layout_columnSpan="2"
android:layout_gravity="fill"
android:layout_rowWeight="1"
android:text="Button4" />
</GridLayout>
运行效果:
今天的分享就回到这里了 ^_^
文章浏览阅读983次。一、基本概念_进程与线程的区别与联系
文章浏览阅读7.9k次,点赞6次,收藏8次。上网上翻了翻,共找到两种方式CSS样式控制,只需将下面代码复制到 vue应用下,index.html文件中的body标签上*{ -webkit-touch-callout:none; /*系统默认菜单被禁用*/ -webkit-user-select:none; /*webkit浏览器*/ -khtml-user-select:none; /*早期浏览器..._禁止输入框文件选中
文章浏览阅读802次。准备工作 申请一个微信测试号 下载一个内网穿透软件用于获取域名 我用的多 wenat软件诺依的开源项目微信授权接口配置位置测试号管理的接口配置中 此处使用内网穿透转换的域名/** * @desc: 门户入口 * @author: cao_wencao * @date: 2019-09-02 17:06 */@Slf4j@AllArgsConstructor@Rest..._wxservice.checksignature false
文章浏览阅读5.7k次,点赞2次,收藏21次。简单介绍一下2022年1月最新的NVMe协议_nvme2.0
文章浏览阅读5.1k次,点赞2次,收藏10次。中转站index.php<?phpif(isset($_GET['param']) && !empty($_GET['param'])){ $param = urldecode($_GET['param']); if(!strpos($param, '?')){ $action = "huidiao.php?param=" .$param.'?1=1'; }else{ $action = "huidiao.php?par
文章浏览阅读77次。2019独角兽企业重金招聘Python工程师标准>>> ..._java给初学者最好理解的讲义
文章浏览阅读4.1w次,点赞19次,收藏43次。【例题】设X和Y的联合密度函数为:f(x,y)={20<x<∞,0<y<∞0其他区域f(x,y)=\left\{\begin{array}{rcl}2 && {0<x<\infty,0<y<\infty}\\0 && 其他区域\end{array}\right.f(x,y)={200<x<∞,0<y<∞其他区域计算(1)P{X>1,Y<1} (2)P{X<Y}类_联合密度函数
文章浏览阅读2.5k次。useEffect里面setState获取不到异步的数据_useeffect setstate异步
文章浏览阅读9.9k次,点赞3次,收藏15次。unity的Axis设置,路径为Edit->Project setting->Input:属性如下:Name:【按键名】该键的名称,可以在脚本编程中直接引用他。比如:Input.GetButtonDown(“Jump”);Descriptive Name:【描述名】在游戏的独立机构中的配置对话框中,当控制值为正时候所显示的名称。默认空白。Negative Descrip..._unity axis snap
文章浏览阅读3k次。近期学习Qt,记录下学习过程,以免忘记。操作环境 WIN7+Qt 5.12.0。新建资源目录 controls,新建 RadioButton.qml文件。RaidoButton包含三个可视项目:background, content item 和 indicator,在默认样式文件中复制相关代码。默认样式文件路径:$QTDIR/qml/QtQuick/Controls.2/RadioButt..._qml radiobutton 自定义
文章浏览阅读425次。1.问题引入: 当使用类模板的成员函数的具体实现与声明分别写在不同的文件时,出现错误,使用vs作为IDE。错误代码:main.cpp#include"person.h"void test01() { Person<string, int> p("赵云", 38); p.showPerson();}int main() { test01(); return 0;..._类模板函数分文件时为什么调用不到
文章浏览阅读6.9k次。豆沙绿的参数为:a. RGB颜色:(199,237,204)b. 十六位颜色代码:C7EDCCc. 色调(Hue)85、饱和度(Sat)123、亮度(Lum)205------------- The End -------------许可协议: 转载请保留原文链接及作者。..._豆沙绿参数