Android 另類的Guide Line - Barrier

ConstraintLayout的Barrier是1.1版本引入的一個非常實用的功能:https://developer.android.com/reference/android/support/constraint/Barrier

Barrier 是用多個View 作為限制源來決定自身位置的一種輔助線



<android.support.constraint.Barrier
        android:id="@+id/barrier1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:barrierDirection="right"
        app:constraint_referenced_ids="button2,button1" />
其中 constraint_referenced_ids 指定限定源id,多個id用逗號隔開

barrierDirection 指定限制的方向,有left、right、top、bottom、start、end, 6種

上面代表的是barrier1 以button2 和button1 兩者最右側為基準線來作為自己的定位

留言

這個網誌中的熱門文章

Android - 使用 adb 安装apk

Android ContentProvider 實現多個應用程式共享資料

Android TextView autosizing 自動調整大小