我在ConstraintLayout中有一个RecyclerView和一个按钮.我希望Button位于顶部,而RecyclerView位于其下方.尝试设置app:layout_constraintTop_toBottomOf="@+id/button"为RecyclerView,但它不尊重.它看起来像这样:
我想在Button下方使用RecyclerView.这是我的代码:
<android.support.constraint.ConstraintLayout
xmlns:android="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">
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="48dp"
android:layout_marginTop="16dp"
android:text="Button"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0" />
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/button" />
</android.support.constraint.ConstraintLayout>
Run Code Online (Sandbox Code Playgroud)
我parent为Button 设置了开始,顶部,结束和底部约束.对于RecyclerView,开始和结束parent以及顶部约束到底部button
我究竟做错了什么?