简介
public class Barrier extends View
| [java.lang.Object](http://developer.android.google.cn/reference/java/lang/Object.html) |
| ↳ | [android.view.View](http://developer.android.google.cn/reference/android/view/View.html) |
| | ↳ | android.support.constraint.Barrier |
一句话简介
Barrier将多个小部件引用为输入,并根据指定端最极端的view创建虚拟指南。就是可以创建个参考view,不会呈现给用户,但是可以用于给其他view定位。
开发者指南
<TextView
android:id="@+id/ddd"
android:text="ddd"
android:layout_width="wrap_content"
app:layout_constraintRight_toRightOf="@id/barrier"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/eee"
android:text="eeeeeeeeeeeeee"
app:layout_constraintTop_toBottomOf="@id/ddd"
app:layout_constraintRight_toRightOf="@id/barrier"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/fff"
android:text="ffffffffffffffffffffffffffffffffffffffff"
android:layout_width="wrap_content"
android:layout_height="18dp"
app:layout_constraintTop_toBottomOf="@id/eee" />
<android.support.constraint.Barrier
android:id="@+id/barrier"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#878784"
app:barrierDirection="end"
app:constraint_referenced_ids="ddd,eee,fff" />
barrierDirection支持属性
- bottom
- top
- left
- right
- start
- end
Barrier构造函数
- Barrier(Context context)
- Barrier(Context context, AttributeSet attrs)
- Barrier(Context context, AttributeSet attrs, int defStyleAttr)
Public method
返回类型 | 方法名 | 备注 |
---|---|---|
int[] | getReferencedIds() | 即获取app:constraint_referenced_ids里的值 |
int | getType() | 返回值见下文 such as Barrier.LEFT |
void | setReferencedIds(int[] ids) | |
void | setType(int type) | such as : Barrier.LEFT |
//barrier type值
public static final int LEFT = 0;
public static final int TOP = 2;
public static final int RIGHT = 1;
public static final int BOTTOM = 3;
public static final int START = 5;
public static final int END = 6;