Module中默認(rèn)的布局就是ConstraintLayout。如下所示:
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.constraintlayout.app.Main2Activity">
在使用ConstraintLayout的布局方案,需要在build.gradle引入支持庫:
dependencies{
compile'com.android.support.constraint:constraint-layout:1.0.1'}
具體使用:
http://blog.csdn.net/guolin_blog/article/details/53122387(郭神的博客)
http://www.lxweimin.com/p/a8b49ff64cd3
常用方法總結(jié)
layout_constraintTop_toTopOf//?將所需視圖的頂部與另一個視圖的頂部對齊。
layout_constraintTop_toBottomOf//?將所需視圖的頂部與另一個視圖的底部對齊。
layout_constraintBottom_toTopOf//?將所需視圖的底部與另一個視圖的頂部對齊。
layout_constraintBottom_toBottomOf//?將所需視圖的底部與另一個視圖的底部對齊。
layout_constraintLeft_toTopOf//?將所需視圖的左側(cè)與另一個視圖的頂部對齊。
layout_constraintLeft_toBottomOf//?將所需視圖的左側(cè)與另一個視圖的底部對齊。
layout_constraintLeft_toLeftOf//?將所需視圖的左邊與另一個視圖的左邊對齊。
layout_constraintLeft_toRightOf//?將所需視圖的左邊與另一個視圖的右邊對齊。
layout_constraintRight_toTopOf//?將所需視圖的右對齊到另一個視圖的頂部。
layout_constraintRight_toBottomOf//?將所需視圖的右對齊到另一個的底部。
layout_constraintRight_toLeftOf//?將所需視圖的右邊與另一個視圖的左邊對齊。
layout_constraintRight_toRightOf//?將所需視圖的右邊與另一個視圖的右邊對齊。
表示wrap content
表示固定值,也就是給控件指定了一個固定的長度或者寬度值。
表示any size,它有點(diǎn)類似于match parent,但和match parent并不一樣,是屬于ConstraintLayout中特有的一種大小控制方式,any size就是用于在ConstraintLayout中頂替match parent.