RecycleView为项目设置了错误的高度 [英] RecycleView set wrong height for items

查看:120
本文介绍了RecycleView为项目设置了错误的高度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I search answer for me, but didn't find work answer for me. I got strange error in viewing my items in RecycleView:

我为RecycleView使用了不同的视图.

I use different view's for RecycleView.

我尝试使用以下代码:

mLayoutManager.setAutoMeasureEnabled(true); // false doesn't work too

但这对我没有帮助.

UPD 1 ,抱歉,我忘了记录.当我启动应用程序时,没有任何错误(如图像上的正常"项目),但是当我开始滚动RecycleView时,我遇到了问题

UPD 1 I forgot note this, sorry. When I start app, I have no errors (items like Normal on image) but when I started scroll my RecycleView I got problem)

UPD 2 我回到了compile 'com.android.support:recyclerview-v7:23.1.1',但这对我没有帮助(所以我用mey RecycleView添加代码和xml,希望您对我有所帮助.

UPD 2 I return back to the compile 'com.android.support:recyclerview-v7:23.1.1', but it doesn't help me (. So I add code and xml with mey RecycleView and I hope you help me.

XML:

<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);

推荐答案

为recyclerview和视口布局父级设置wrap_content. 这对我有用.

Set wrap_content for the recyclerview and for your viewholder layout parent. This worked for me.

这篇关于RecycleView为项目设置了错误的高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆