我知道ConstraintLayout是从android studio 2.2提供的。
但是,是否也提供了任何ConstraintLayoutManager?
(类似于LinearLayoutManager)
这样我们就可以在RecyclerView等中使用它了。
答案 0 :(得分:4)
没有。还没有。如果您只想使用RecyclerView,请使用LinearLayoutManager。
答案 1 :(得分:0)
您可以像这样将ConstraintLayout添加到LinearLayout。
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/recycleritem_id"
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_marginTop="8dp"
android:gravity="start"
android:orientation="horizontal"
android:clickable="true"
android:background="?attr/selectableItemBackground">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="22dp"
android:text="TextView"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>