国产精品天干天干,亚洲毛片在线,日韩gay小鲜肉啪啪18禁,女同Gay自慰喷水

歡迎光臨散文網(wǎng) 會(huì)員登陸 & 注冊(cè)

Android開(kāi)發(fā)學(xué)習(xí)教程(12)- Android布局之線性布局LinearLayout

2023-01-27 16:04 作者:考研保研直通車  | 我要投稿


—— 當(dāng)下的生活或許疲憊又難熬,但你要相信,始終沒(méi)有放棄過(guò)的你,一定會(huì)過(guò)上想要的生活。

上一篇我們講了對(duì)話框AlertDialog的基本用法,這里來(lái)學(xué)習(xí)常用布局之線性布局的基本用法。

線性布局是什么

線性布局中的控件按照橫向或豎向排列,并且線性布局不會(huì)換行,當(dāng)控件超出屏幕邊緣,后面的控件就被隱藏,不會(huì)被顯示出來(lái)。

線性布局有什么用

控制其中的控件只能橫向或豎向排列。

線性布局怎么用

繼續(xù)基于上一篇的項(xiàng)目,我們新建一個(gè)LinearLayoutActivity:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?xml?version="1.0"?encoding="utf-8"?>
<LinearLayout?xmlns:android="http://schemas.android.com/apk/res/android"
????android:layout_width="match_parent"
????android:layout_height="match_parent"
????android:gravity="center"
????android:orientation="horizontal">
????<TextView
????????android:layout_width="wrap_content"
????????android:layout_height="wrap_content"
????????android:text="Hello 我是第一個(gè)子控件"?/>
????<TextView
????????android:layout_width="wrap_content"
????????android:layout_height="wrap_content"
????????android:text="Hello 我是第二個(gè)子控件"?/>
????<TextView
????????android:layout_width="wrap_content"
????????android:layout_height="wrap_content"
????????android:text="Hello 我是第三個(gè)子控件"?/>
????<TextView
????????android:layout_width="wrap_content"
????????android:layout_height="wrap_content"
????????android:text="Hello 我是第四個(gè)子控件"?/>
????<TextView
????????android:layout_width="wrap_content"
????????android:layout_height="wrap_content"
????????android:text="Hello 我是第五個(gè)子控件"?/>
</LinearLayout>

上圖橫向排列了五個(gè)控件,并且線性布局不會(huì)自動(dòng)換行,當(dāng)控件超出屏幕邊緣,后面的控件就被隱藏,不會(huì)被顯示出來(lái)。

LinearLayout基本屬性

android:gravity:用來(lái)控制子控件的位置,值有top,left,right,bottom,center,分別表示子控件在頂部、左部、右部、下部、垂直方向居中并且水平方向居中,值得注意的是,還可以組合取值,如right|center_vertical表示子控件在右部并且垂直方向居中;

android:orientation:用來(lái)控制子控件的排列方式,值為horizontal時(shí)表示所有子控件橫向排列,為vertical時(shí)表示所有子控件豎向排列,上面的例子是橫向排列,我們來(lái)試試豎向排列;

把a(bǔ)ndroid:orientation改為vertical,為了使效果更明顯,我們?nèi)サ鬭ndroid:gravity設(shè)置,使用默認(rèn)值(top|left),運(yùn)行如下:

源碼鏈接:https://yunjunet.cn/876750.html

Android開(kāi)發(fā)學(xué)習(xí)教程(12)- Android布局之線性布局LinearLayout的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國(guó)家法律
定安县| 名山县| 武威市| 泉州市| 增城市| 肇源县| 东丰县| 辽中县| 涡阳县| 德保县| 顺义区| 和平区| 宁都县| 信宜市| 大丰市| 荣成市| 永和县| 罗定市| 天长市| 遂川县| 临猗县| 宣威市| 清丰县| 葫芦岛市| 漠河县| 大连市| 屏南县| 岳池县| 石棉县| 昌江| 桃园市| 阿拉尔市| 桂东县| 图木舒克市| 大竹县| 南江县| 韩城市| 屏边| 通城县| 武强县| 济阳县|