RelativeLayout相對佈局是個人覺得在android佈局中比較常用且好用的一個,當然如果想讓佈局更漂亮是需要多種佈局混合搭建的,這裏就需要更深入的學習了,在這隻介紹下有關相對佈局的東西。
相對於兄弟元素
android:layout_below="@id/aaa":在指定View的下方
android:layout_above="@id/xxx":在指定View的上方
android:layout_toLeftOf="@id/bbb":在指定View的左邊
android:layout_toRightOf="@id/cccc":在指定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一樣了。
【android學習筆記】關於相對佈局RelativeLayout的各種屬性介紹
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章
天天記錄 - Android View座標getLeft, getRight, getTop, getBotto
1 引起疑惑 分析視圖invalidate流程的過程中發現view的left, right, top, bottom跟自己理解的不一樣,現在想分析一下這幾個值具體的含義。 2 理解座標,位置概念
jf3612797
2020-06-22 03:11:09
城市更新【綜合整治】局部調出研究——手上正趕上真實案例探討
城市更新
2020-03-13 15:37:00
android ViewFlipper的使用
jf3612797
2020-02-25 03:35:01
android自定義佈局中的平滑移動
jf3612797
2020-02-25 03:35:01
android 中文 api (64) —— Scroller
jf3612797
2020-02-25 03:35:01
android:installLocation簡析
jf3612797
2020-02-25 03:35:01
ViewConfiguration中的getScaledTouchSlop()的作用
jf3612797
2020-02-25 03:35:01
requestDisallowInterceptTouchEvent
jf3612797
2020-02-25 03:35:01
Android-ListView幾個比較特別的屬性
jf3612797
2020-02-25 03:35:01
android:screenOrientation的說明
jf3612797
2020-02-25 03:35:01
android:descendantFocusability用法簡析
jf3612797
2020-02-25 03:35:01
天天記錄 - Android View座標getLeft, getRight, getTop, getBotto
1 引起疑惑 分析視圖invalidate流程的過程中發現view的left, right, top, bottom跟自己理解的不一樣,現在想分析一下這幾個值具體的含義。 2 理解座標,位置概念
jf3612797
2020-06-22 03:11:09
android ViewFlipper的使用
jf3612797
2020-02-25 03:35:01
android自定義佈局中的平滑移動
jf3612797
2020-02-25 03:35:01