我正在尝试按http://www.androidhive.info/2016/01/android-working-with-recycler-view/上的教程 实现一个recyclerView,到目前为止,一切都已经计划好了。
滚动并回收元素后,会使用大量填充重新创建它们(如此处所示https://youtu.be/jkGLLRnjtN0)
我不知道为什么会这样做,有人可以解释一下吗?感谢
编辑:我的行布局xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:focusable="true"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:clickable="true"
android:background="?android:attr/selectableItemBackground"
android:orientation="vertical">
<TextView
android:id="@+id/title"
android:textColor="#000"
android:textSize="16dp"
android:textStyle="bold"
android:layout_alignParentTop="true"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/year"
android:textColor="#000"
android:layout_width="wrap_content"
android:layout_alignParentRight="true"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/genre"
android:layout_below="@id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</RelativeLayout>
答案 0 :(得分:0)
尝试将父行布局的高度更改为wrap_content或固定dpi。
由于此更改,请务必仔细检查项目视图的布局参数:现在将完全遵循先前忽略的布局参数(例如滚动方向中的MATCH_PARENT)。
NumberFormat