Android教程網
  1. 首頁
  2. Android 技術
  3. Android 手機
  4. Android 系統教程
  5. Android 游戲

Android RelativeLayout 對齊屬性整理

編輯:關於 Android 程式設計

RelativeLayout 允許子元件彼此定位,也允許元件與父容器對齊。掌握常見屬性後,多數簡單版面都能快速完成。

相對其他元件

android:layout_above 可把元件放在指定 id 上方;android:layout_below 放在下方;android:layout_toLeftOf 讓右邊緣對齊目標左側;android:layout_toRightOf 讓左邊緣對齊目標右側。若需要邊緣對齊,可用 layout_alignLeft、layout_alignRight、layout_alignTop、layout_alignBottom 或 layout_alignBaseline。

相對父容器

若要和父元件對齊,可用 layout_alignParentLeft、layout_alignParentRight、layout_alignParentTop、layout_alignParentBottom。置中則可用 layout_centerHorizontal、layout_centerVertical 或 layout_centerInParent。

  1. 上一篇文章:
  2. 下一篇文章:
Copyright © Android教程網 All Rights Reserved