ConstraintLayout下RecyclerView不显示

昨天遇到的一个巨坑的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,等待高人的指点,谢谢。

最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容