標籤:tab tla bottom near 最小 baseline 外邊距 int tle
安卓除了有6種最基本的布局線性布局(LinearLayout)、相對布局(RelativeLayout)、幀布局(FrameLayout)、網格布局(GridLayout)、絕對布局(AbsoluteLayout)、表格版面配置(TableLayout)外還有一些較複雜的布局,如ConstraintLayout。
1、優點
調整控制項的位置和大小時更加靈活,功能更強大。
2、繼承關係
和其他布局一樣繼承自ViewGroup。
3、新特性
相對定位:
<Button android:id="@+id/buttonA" ... />
<Button android:id="@+id/buttonB" ...
app:layout_constraintLeft_toRightOf="@+id/buttonA" />
按鈕b的靠右對齊按鈕a
- layout_constraintLeft_toLeftOf // 左邊靠左對齊
- layout_constraintLeft_toRightOf // 左邊靠右對齊
- layout_constraintRight_toLeftOf // 右邊靠左對齊
- layout_constraintRight_toRightOf // 右邊靠右對齊
- layout_constraintTop_toTopOf // 上邊頂部對齊
- layout_constraintTop_toBottomOf // 上邊底部對齊
- layout_constraintBottom_toTopOf // 下邊頂部對齊
- layout_constraintBottom_toBottomOf // 下邊底部對齊
- layout_constraintBaseline_toBaselineOf // 常值內容基準線對齊
- layout_constraintStart_toEndOf // 起始邊向尾部對齊
- layout_constraintStart_toStartOf // 起始邊向起始邊對齊
- layout_constraintEnd_toStartOf // 尾部向起始邊對齊
- layout_constraintEnd_toEndOf // 尾部向尾部對齊
外邊距:
<android.support.constraint.ConstraintLayout ...>
<Button android:id="@+id/button" ...
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent/>
<android.support.constraint.ConstraintLayout/>
空間置中效果
傾向:
<android.support.constraint.ConstraintLayout ...>
<Button android:id="@+id/button" ...
app:layout_constraintHorizontal_bias="0.3"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent/>
<android.support.constraint.ConstraintLayout/>
左邊佔0.3,右邊佔0.7
可見度的表現:
尺寸約束:
android:minWidth 設定布局的最小寬度
android:minHeight 設定布局的最小高度
CHAIN:
協助工具輔助:
安卓ConstraintLayout布局