昨天遇到的一个巨坑的Bug,就下面这个简单的布局,在约束布局中把RecyclerView的宽高都设置为match_parent,然后,然后神奇的事情发生了,RecyclerView很正常的充满了整个屏幕,但是他的item一个都显示不出来,查了半天,其他地方一点问题都没有。
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.qg.gankio.ui.TodayActivity">
<com.qg.gankio.widget.LoadMoreRecyclerView
android:id="@+id/todayList"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="0dp"
android:layout_marginEnd="0dp"
android:layout_marginStart="0dp"
android:layout_marginTop="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>
最后突发奇想把RecyclerView的宽高设置为0dp,他就神奇的好了,小白暂时搞不清楚为什么会有这样的bug,等待高人的指点,谢谢。
博客讲述了作者在使用ConstraintLayout时遇到RecyclerView不显示的问题。尽管RecyclerView占据了整个屏幕空间,但其items无法正常显示。通过将RecyclerView的宽高改为0dp,问题得到解决,但作者对这一bug的原因仍不清楚,期待进一步的解释。
2033

被折叠的 条评论
为什么被折叠?



