Android相對布局RelativeLayout各屬性介紹

來源:互聯網
上載者:User

標籤:relativelayout   android   相對布局   

Android相對布局RelativeLayout各屬性介紹

相對於兄弟元素
android:layout_below="@id/xxx":在指定View的下方
android:layout_above="@id/xxx":在指定View的上方
android:layout_toLeftOf="@id/xxx":在指定View的左邊
android:layout_toRightOf="@id/xxx":在指定View的右邊
相對於父元素
android:layout_alignParentLeft="true":在父元素內左邊
android:layout_alignParentRight="true":在父元素內右邊
android:layout_alignParentTop="true":在父元素內頂部
android:layout_alignParentBottom="true":在父元素內底部
對齊
android:layout_centerInParent="true":置中布局
android:layout_centerVertical="true":水平置中布局
android:layout_centerHorizontal="true":垂直置中布局
android:layout_alignTop="@id/xxx":與指定View的上邊界一致
android:layout_alignBottom="@id/xxx":與指定View下邊界一致
android:layout_alignLeft="@id/xxx":與指定View的左邊界一致
android:layout_alignRight="@id/xxx":與指定View的右邊界一致
間隔
android:layout_marginBottom=""; 離某元素底邊緣的距離
android:layout_marginLeft=""; 離某元素左邊緣的距離
android:layout_marginRight ="";離某元素右邊緣的距離
android:layout_marginTop=""; 離某元素上邊緣的距離
android:layout_paddingBottom=""; 離父元素底邊緣的距離
android:layout_paddingLeft=""; 離父元素左邊緣的距離
android:layout_paddingRight ="";離父元素右邊緣的距離
android:layout_paddingTop=""; 離父元素上邊緣的距離

 

margin 與padding 的區別問題
padding是站在父view的角度描述問題,是自己與其父控制項的邊之間的距離。margin則是站在自己的角度描述問題,自己與旁邊的某個組件的距離,如果同一級只有一個view,那麼它的效果基本上就和padding一樣了。

 650) this.width=650;" src="http://images0.cnblogs.com/blog2015/677694/201506/222248132209266.png" />


Android相對布局RelativeLayout各屬性介紹

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.