自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

Android學(xué)習(xí)筆記:Layout.xml屬性

移動(dòng)開發(fā) Android
在Android開發(fā)中,會(huì)經(jīng)常接觸到布局文件Layout.xml,Layout對于迅速的搭建界面和提高界面在不同分辨率的屏幕上的適應(yīng)性具有很大的作用。下面將給大家介紹Layout.xml的屬性和實(shí)現(xiàn)。

Layout對于迅速的搭建界面和提高界面在不同分辨率的屏幕上的適應(yīng)性具有很大的作用。這里簡要介紹Android的Layout和研究一下它的實(shí)現(xiàn)。

Android有Layout:FrameLayout,LinearLayout,TableLayout,RelativeLayout,AbsoluteLayout。

放入Layout中進(jìn)行排布的View的XML屬性:

1.幾種Layout中Item所共有的XML屬性:

(1)layout_width

(2)layout_height

(3)layout_marginLeft

(4)layout_marginTop

(5)layout_marginRight

(6)layout_marginBottom

(7)layout_gravity

FrameLayout是最簡單的Layout,就只具有這些屬性。

LinearLayout還會(huì)有:

(8)layout_weight

TableLayout的行TableRow是一個(gè)橫向的(horizontal)的LinearLayout。

RelativeLayout有16個(gè)align相關(guān)的XML屬性:

(9)layout_above

(10)layout_alignBaseline

(11)layout_alignBottom

(12)layout_alignLeft

(13)layout_alignParentBottom

(14)layout_alignParentLeft

(15)layout_alignParentRight

(16)layout_alignParentTop

(17)layout_alignRight

(18)layout_alignTop

(19)layout_below

(20)layout_centerHorizontal

(21)layout_centerInParent

(22)layout_centerVertical

(23)layout_toLeftOf

(24)layout_toRightOf

(1)和(2)用來確定放入Layout中的View的寬度和高度:它們的可能取值為fill_parent,wrap_content或者固定的像素值。

(3)(4)(5)(6)是放入Layout中的View期望它能夠和Layout的邊界或者其他View之間能夠相距一段距離。

(7)用來確定View在Layout中的??课恢谩?/p>

(8)用于在LinearLayout中把所有子View排布之后的剩余空間按照它們的layout_weight分配給各個(gè)擁有這個(gè)屬性的View。

(9)到(24)用來確定RelativeLayout中的View相對于Layout或者Layout中的其他View的位置。

根據(jù)Android的文檔,Android會(huì)對Layou和View嵌套組成的這棵樹進(jìn)行2次遍歷,一次是measure調(diào)用,用來確定Layout或者View的大小;一次是layout調(diào)用,用來確定Layout或者view的位置。當(dāng)然后來我自己的山寨實(shí)現(xiàn)把這2次調(diào)用合并到了一起。那就是Layout在排布之前都對自己進(jìn)行measure一次,然后對View遞歸調(diào)用Layout方法。這樣子的大小肯定是確定了的。然后用確定了的大小來使用gravity或者align屬性來定位,使用margin來調(diào)整位置。

【編輯推薦】

  1. Android學(xué)習(xí)筆記:androidmanifest.xml解析
  2. 移動(dòng)開發(fā)基礎(chǔ)教程:Android是什么
  3. Android SDK工具:使用layoutopt進(jìn)行布局優(yōu)化
  4. PlayBook運(yùn)行Android應(yīng)用的五大細(xì)節(jié)
  5. Kindle和Android開發(fā)的比較

 

責(zé)任編輯:佚名 來源: 博客園
相關(guān)推薦

2013-06-08 13:07:54

Android開發(fā)Android UILayout XML屬

2011-03-30 17:32:28

androidmaniAndroid開發(fā)

2013-06-28 13:38:45

AndroidAndroidMani

2013-04-01 14:35:10

Android開發(fā)Android自定義x

2017-05-24 18:00:13

AndroidAndroid DatView

2012-05-14 17:06:46

iOS

2010-08-25 15:15:52

CSSclip

2022-09-21 14:42:03

JSProps屬性

2011-06-03 13:11:19

Android Activity

2011-09-09 13:59:17

Android wid

2011-04-12 17:16:52

Activity跳轉(zhuǎn)開發(fā)實(shí)例Android學(xué)習(xí)筆記

2010-09-10 09:22:50

DIV布局

2011-09-07 10:34:48

Android Wid

2013-04-03 14:58:43

Android學(xué)習(xí)筆記實(shí)用代碼合集

2011-09-07 11:15:25

2023-12-11 07:34:37

Computed計(jì)算屬性Vue3

2010-09-02 10:16:43

fixedCSS

2011-05-30 14:00:35

Android Activity Intent

2009-09-14 14:47:57

XML節(jié)點(diǎn)

2013-06-08 13:02:11

Android開發(fā)XML解析
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)