ali*_*awi 21 android android-recyclerview android-constraintlayout
我正在尝试在wrap_content上设置回收器视图的高度并使其尊重,但它将超过布局上的其他窗口小部件.我现在能做什么?
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white">
<TextView
android:id="@+id/tvPastRounds"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginTop="0dp"
android:text="Past Rounds"
android:textColor="@color/text_color_black"
android:textSize="16sp"
app:layout_constraintLeft_toLeftOf="parent"/>
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginBottom="24dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:layout_marginTop="16dp"
android:clipChildren="true"
android:maxHeight="150dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintLeft_toLeftOf="@+id/tvPastRounds"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tvPastRounds" app:layout_constraintVertical_bias="0.0"/>
</android.support.constraint.ConstraintLayout>
Run Code Online (Sandbox Code Playgroud)
Rez*_*ini 56
我有同样的问题,我找到了这个解决方案:您应该将此属性添加到您的recyclerview,它会在constraint_layout中使您的recyclerview wrap_content:
app:layout_constraintHeight_default="wrap"
Run Code Online (Sandbox Code Playgroud)
如果此解决方案解决了您的问题,请告诉我.
编辑:回收者的身高应该是0dp.
编辑2:在较新版本的支持库中,使用以下代码:
android:layout_height="wrap_content"
app:layout_constrainedHeight="true"
Run Code Online (Sandbox Code Playgroud)
Joh*_*ker 12
app:layout_constraintHeight_default="wrap"
Run Code Online (Sandbox Code Playgroud)
在较新版本的支持库中已弃用,因此请考虑使用
android:layout_height="wrap_content"
app:layout_constrainedHeight="true"
Run Code Online (Sandbox Code Playgroud)
代替.
| 归档时间: |
|
| 查看次数: |
10890 次 |
| 最近记录: |