Android布局檔案屬性筆記)

來源:互聯網
上載者:User

屬性 

說明

說明

android:id

為控制項指定相應的ID

 

android:text

指定控制項當中顯示的文字,需要注意的是,這裡盡量使用strings.xml檔案當中的字串

 

android:gravity

指定View組件的對齊,比如說置中,居右等位置 這裡指的是控制項中的文本位置並不是控制項本身

 

android:layout_gravity

指定Container組件的對齊.比如一個button 在linearlayout裡,你想把該button放在靠左、靠右等位置就可以通過該屬性設定.以button為 例,android:layout_gravity="right"則button靠右

 

android:textSize

指定控制項當中字型的大小

 

android:background

指定該控制項所使用的背景色,RGB命名法

 

android:width

指定控制項的寬度

 

android:height

指定控制項的高度

 

android:layout_width

指定Container組件的寬度

 

android:layout_height

指定Container組件的高度

 

android:layout_weight

View中很重要的屬性,按比例劃分空間

 

android:padding*

指定控制項的內邊距,也就是說控制項當中的內容

 

android:sigleLine

如果設定為真的話,則控制項的內容在同一行中進行顯示

 

android:scaleType

是控製圖片如何resized/moved來匹對ImageView的siz

 

android:layout_centerHrizontal

水平置中

 

android:layout_centerVertical

垂直置中

android:layout_centerInparent

相對於父元素完全置中

 

android:layout_alignParentBottom

貼緊父元素的下邊緣

 

android:layout_alignParentLeft

貼緊父元素的左邊緣

 

android:layout_alignParentRight

貼緊父元素的右邊緣

 

android:layout_alignParentTop

貼緊父元素的上邊緣

 

android:layout_alignWithParentIfMissing

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

 

android:layout_below    

在某元素的下方

 

android:layout_above    

在某元素的的上方

 

android:layout_toLeftOf 

在某元素的左邊

 

android:layout_toRightOf

在某元素的右邊

 

android:layout_alignTop 

本元素的上邊緣和某元素的的上邊緣對齊

 

android:layout_alignLeft

本元素的左邊緣和某元素的的左邊緣對齊

 

android:layout_alignBottom

本元素的下邊緣和某元素的的下邊緣對齊

 

android:layout_alignRight

本元素的右邊緣和某元素的的右邊緣對齊

 

android:layout_marginBottom 

離某元素底邊緣的距離

 

android:layout_marginLeft   

離某元素左邊緣的距離

 

android:layout_marginRight    

離某元素右邊緣的距離

 

android:layout_marginTop 

離某元素上邊緣的距離

 

android:paddingLeft    

本元素內容離某元素右邊緣的距離

 

android:paddingRight 

本元素內容離某元素上邊緣的距離

 

android:hint

設定EditText為空白時輸入框內的提示資訊

 

android:LinearLayout

它確定了LinearLayout的方向,其值可以為vertical, 表示垂直布局horizontal, 表示水平布局

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.