概述:網(wǎng)格布局相對(duì)于表格布局來說自由度更高,是以行數(shù)和列數(shù)來確定位置進(jìn)行排列。就像一間教室,確定好行數(shù)與列數(shù)就能讓同學(xué)有序入座。
1. 可以設(shè)置布局中組件的排列方式
2. 可以自定行列數(shù)
GridLayout 常用布局標(biāo)簽:
<android:columnCount="4"
:設(shè)置最大列數(shù),這里設(shè)置為4。
<android:rowCount="5"
:設(shè)置最大行數(shù),這里設(shè)置為6。
<android:orientation="horizontal"
:設(shè)置元素布局方向,這里設(shè)置為平行。
GridLayout 單元格常用布局標(biāo)簽:
<android:layout_row="0"
:指定單元格的顯示的列數(shù),這里設(shè)置控件的列數(shù)為第1列。
<android:layout_column="3"
:指定單元格顯示的列數(shù),設(shè)置控件的行數(shù)為第4列。
<android:layout_columnSpan="2"
:指定單元格占據(jù)的列數(shù)。
<android:layout_rowSpan="2"
:指定單元格占據(jù)的行數(shù)。文章來源:http://www.zghlxwxcb.cn/news/detail-403775.html
簡(jiǎn)易計(jì)算機(jī) 代碼示例
文章來源地址http://www.zghlxwxcb.cn/news/detail-403775.html
<?xml version="1.0" encoding="utf-8"?>
<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_gravity="center"
android:columnCount="4"
android:orientation="horizontal">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="/"
android:layout_row="0"
到了這里,關(guān)于Android基本布局-GridLayout_網(wǎng)格布局的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!