五月天青色头像情侣网名,国产亚洲av片在线观看18女人,黑人巨茎大战俄罗斯美女,扒下她的小内裤打屁股

歡迎光臨散文網(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ó)家法律
海城市| 通城县| 贵州省| 南投县| 张北县| 玉溪市| 清苑县| 胶州市| 鹤岗市| 博兴县| 社旗县| 潢川县| 盐城市| 宁远县| 肃北| 米脂县| 阜宁县| 墨脱县| 辉县市| 岢岚县| 天津市| 共和县| 藁城市| 瑞金市| 八宿县| 临泽县| 永丰县| 健康| 福海县| 阿拉善右旗| 吉安县| 英吉沙县| 林芝县| 汽车| 彝良县| 施秉县| 浠水县| 浦北县| 车险| 四川省| 姜堰市|