as初入门,碰到了ConstraintLayout下使用RecycleView会覆盖其他布局
预览时正常显示,一运行会发现RecycleView遮住其他布局,在网上找了很多办法,有的说加layout_constrainedHeight="true"(这个我没成功),最后找到了一个能解决我自己遮挡问题的方法就是把layout_width、layout_height设为0dp,再设置约束运行时就不会遮住了。
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/linearLayout2"
app:layout_constraintVertical_bias="0.0"
关于layout_width、layout_height设为0dp的意思:按比例显示LinearLayout内各个子控件,当该控件android:layout_width或者android:layout_height为0dp,此时该控件占用LinearLayout的比例为:本控件weight值 / LinearLayout内所有控件的weight值的和,即设置“0dp”可以自己按照你所设置的比例进行显示。