Android RecycleView为项目设置了错误的高度

Android RecycleView为项目设置了错误的高度,android,android-recyclerview,Android,Android Recyclerview,我为我寻找答案,但没有找到适合我的工作答案。在RecycleView中查看我的项目时出现奇怪的错误: 我对RecycleView使用不同的视图 我尝试使用以下代码: mLayoutManager.setAutoMeasureEnabled(true); // false doesn't work too 但这对我没有帮助 UPD 1对不起,我忘了记下这个。当我启动应用程序时,我没有任何错误(图像上的正常项目),但当我开始滚动我的RecycleView时,我遇到了问题) UPD2我返回到编译'

我为我寻找答案,但没有找到适合我的工作答案。在
RecycleView
中查看我的项目时出现奇怪的错误:

我对RecycleView使用不同的视图

我尝试使用以下代码:

mLayoutManager.setAutoMeasureEnabled(true); // false doesn't work too
但这对我没有帮助

UPD 1对不起,我忘了记下这个。当我启动应用程序时,我没有任何错误(图像上的正常项目),但当我开始滚动我的
RecycleView
时,我遇到了问题)

UPD2我返回到
编译'com.android.support:RecycleView-v7:23.1.1'
,但它对我没有帮助(.因此我用mey
RecycleView添加代码和xml
,希望你能帮助我

XML:


为recyclerview和viewholder布局父级设置
wrap\u内容。

这对我很有用。

设置
包装内容
而不是
匹配父项
(如果设置为
匹配父项
)因为这会导致布局与提供大空间的父级匹配。

我遇到了相同的问题。如果您只将
RecyclerView
更改为
wrap\u content
,启动页面看起来很好,但在向上滑动后会出现空白

解决方案: 除了将
RecyclerView
android:layout\u height
更改为
wrap\u content
,您还应该转到
RecyclerView
项目所在的布局XML文件,并将周围的相对论视图的
android:layout\u height
属性修改为
wrap\u content


请参阅。

你的recyclerview的布局高度是多少?@Amit Tiwari我使用wrap\u内容。如果我设置了match\u parent,我在滚动之前遇到了这个问题。现在,使用wrap\u内容,我在开始滚动时遇到了这个问题早期版本的支持库中的wrap\u内容有一些问题,但在23.2版本中,他们已经修复了这个问题e wrap_content表示回收器视图的高度。因此,此版本中可能仍然存在错误。请尝试将回收器视图的布局高度设置为某个静态值,例如500dp,然后查看它是否正常工作。@AmitTiwari我无法设置固定大小,因为我在RecycleView中有不同的项(((您尝试调用SetMeasurementCachenabled(false))吗在mLayoutManager上?在android上使用RelativeLayout:layout\u height=“wrap\u content”仍然不会显示嵌套回收视图的内容。如果我设置了高度,则项目显示没有问题。
<android.support.v7.widget.RecyclerView
    android:id="@+id/dashboard_recycle_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:clipToPadding="false"
    android:scrollbars="none" />
    mRecyclerView = (RecyclerView) parent.findViewById(R.id.dashboard_recycle_view);
    mLayoutManager = new LinearLayoutManager(getContext());
    mLayoutManager.setAutoMeasureEnabled(false);
    mRecyclerView.setLayoutManager(mLayoutManager);
    mRecyclerView.setHasFixedSize(false);
    mRecyclerView.setAdapter(mRecycleAdapter);