ConstraintLayout 平分布局

添加依赖

compile 'com.android.support.constraint:constraint-layout:1.0.2'

创建布局

"1.0" encoding="utf-8"?>
"http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    

需要了解的地方

  1. 宽度为0dp android:layout_width="0dp"
  2. 需要准确指定左右的约束 app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toLeftOf="@+id/bt_b"//使用@id 编译不通过,使用@+id就可以了
  3. 指定权重 app:layout_constraintHorizontal_weight="1"
  4. 约束也可以为parent app:layout_constraintBottom_toBottomOf="parent"

转载于:https://juejin.im/post/5a31ee3af265da43294e0fe1

你可能感兴趣的:(ConstraintLayout 平分布局)