天天看點

android 相對布局屬性說明

[b] [size=large]常用的一些屬性說明[/size][/b]

android:id --- 為控件指定相應的ID

android:text --- 指定控件當中顯示的文字,需要注意的是,這裡盡量使用strings.xml檔案當中的字元串

android:grivity --- 指定控件的基本位置,比如說居中,居右等位置 這裡指的是控件中的文本位置并不是控件本身。

android:textSize --- 指定控件當中字型的大小

android:background --- 指定該控件所使用的背景色,RGB命名法

android:width --- 指定控件的寬度

android:height --- 指定控件的高度

android:padding* --- 指定控件的内邊距,也就是說控件當中的内容

android:sigleLine --- 如果設定為真的話,則控件的内容在同一行中進行顯示

[color=red]下邊是相對布局屬性的說明:RelativeLayout[/color]

android:layout_above 将該控件的底部至于給定ID控件之上

android:layout_below 将該控件的頂部至于給定ID的控件之下

android:layout_toLeftOf 将該控件的右邊緣和給定ID的控件左邊緣對齊

android:layout_toRightOf 将該控件的左邊緣和給定ID的控件的右邊緣對齊

android:layout_alignBaseline 該控件的baseline和給定ID的控件的baseline對齊

android:layout_alignBottom 将該控件的底部邊緣與給定ID控件的底部邊緣對齊

android:layout_alignLeft 将該控件的左邊緣與給定ID控件的左邊緣對齊

android:layout_alignRight 将該控件的右邊緣與給定ID控件的右邊緣對齊

android:layout_alignTop 将該控件的頂部邊緣與給定ID控件的頂部對齊

android:alignParentBottom 如果該值為true,則将該控件的底部和父控件的底部對齊

android:layout_alignParentLeft 如果該值為true,則将該控件左邊與父控件的左邊對齊

android:layout_alignParentRight 如果該值為true,則将該控件的右邊與父控件的右邊對齊

android:layout_alignParentTop 如果該值為true,則将該控件的頂部與父控件的頂部對齊

android:layout_centerHorizontal 如果為真,該控件将被至于水準方向的中央

android:layout_centerInParent 如果為真, 該控件将被至于父控件水準方向和垂直方向的中央

android:layout_centerVertical 如果為真,該控件将被至于垂直方向的中央

android:layout_marginLeft此屬性用來設定控件之間的間隙(控件和控件之間和内邊距不同)

android:padding="3dip"說明了四邊的内邊距是3dip

[color=red]TableLayout[/color]

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"

android:orientation="vertical"

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:stretchColumns="0"

></TableLayout>

android:stretchColumns="0"第一列作為拉伸列填滿整行

[color=red]EditText 屬性說明[/color]

android:scrollHorizontally

設定文本超出TextView的寬度的情況下,是否出現橫拉條。

下面的 更清晰些。[color=red]----------------------------------------------------[/color]

第一類:屬性值為true或false

android:layout_centerHrizontal 水準居中

android:layout_centerVertical 垂直居中

android:layout_centerInparent 相對于父元素完全居中

android:layout_alignParentBottom 貼緊父元素的下邊緣

android:layout_alignParentLeft 貼緊父元素的左邊緣

android:layout_alignParentRight 貼緊父元素的右邊緣

android:layout_alignParentTop 貼緊父元素的上邊緣

android:layout_alignWithParentIfMissing 如果對應的兄弟元素找不到的話就以父元素做參照物

第二類:屬性值必須為id的引用名“@id/id-name”

android:layout_below 在某元素的下方

android:layout_above 在某元素的的上方

android:layout_toLeftOf 在某元素的左邊

android:layout_toRightOf 在某元素的右邊

android:layout_alignTop 本元素的上邊緣和某元素的的上邊緣對齊

android:layout_alignLeft 本元素的左邊緣和某元素的的左邊緣對齊

android:layout_alignBottom 本元素的下邊緣和某元素的的下邊緣對齊

android:layout_alignRight 本元素的右邊緣和某元素的的右邊緣對齊

第三類:屬性值為具體的像素值,如30dip,40px

android:layout_marginBottom 離某元素底邊緣的距離

android:layout_marginLeft 離某元素左邊緣的距離

android:layout_marginRight 離某元素右邊緣的距離

android:layout_marginTop 離某元素上邊緣的距離

EditText的android:hint

設定EditText為空時輸入框内的提示資訊。

android:gravity 

android:gravity屬性是對該view 内容的限定.比如一個button 上面的text. 你可以設定該text 在view的靠左,靠右等位置.以button為例,android:gravity="right"則button上面的文字靠右

android:layout_gravity

android:layout_gravity是用來設定該view相對與起父view 的位置.比如一個button 在linearlayout裡,你想把該button放在靠左、靠右等位置就可以通過該屬性設定.以button為例,android:layout_gravity="right"則button靠右

android:layout_alignParentRight

使目前控件的右端和父控件的右端對齊。這裡屬性值隻能為true或false,預設false。

以後繼續積累,繼續整理。