出來時(shí)間也不短了,然后最近才研究,寫下心得
1.替換LinearLayout的wight屬性
<android.support.constraint.ConstraintLayout android:layout_width="match_parent" android:layout_height="wrap_content" app:layout_constraintTop_toTopOf="parent"> <TextView android:id="@+id/tvTextWight1" android:layout_width="0dp" android:layout_height="wrap_content" android:background="@android:color/holo_red_dark" android:minHeight="30dp" android:text="哈哈哈" app:layout_constraintHorizontal_weight="1" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toLeftOf="@+id/tvTextWight2" app:layout_constraintTop_toTopOf="parent" /> <TextView android:id="@+id/tvTextWight2" android:layout_width="0dp" android:layout_height="wrap_content" android:background="@android:color/holo_green_dark" android:minHeight="30dp" android:text="啦啦啦" app:layout_constraintHorizontal_weight="1" app:layout_constraintLeft_toRightOf="@+id/tvTextWight1" app:layout_constraintRight_toLeftOf="@+id/tvTextWight3" app:layout_constraintTop_toTopOf="parent" /> <TextView android:id="@+id/tvTextWight3" android:layout_width="0dp" android:layout_height="wrap_content" android:background="@android:color/holo_orange_dark" android:minHeight="30dp" android:text="嘿嘿嘿" app:layout_constraintHorizontal_weight="1" app:layout_constraintLeft_toRightOf="@+id/tvTextWight2" app:layout_constraintRight_toRightOf="parent" app:layout_constraintTop_toTopOf="parent" /></android.support.constraint.ConstraintLayout>
注意務(wù)必形成鏈才能使用,
注意最左邊和最右邊的view
app:layout_constraintLeft_toLeftOf="" (左邊挨著XXX左邊)
app:layout_constraintLeft_toRightOf=""(左邊挨著XXX右邊)
其他屬性類推