回收者观点之间的巨大差距
Wide gaps between recycler views
我刚刚将 Android 支持库的新更新安装到版本 23.2.1.0,当我 运行 项目时,我遇到了一个以前没有的问题。我正在使用显示在 recyclerview 容器内的卡片视图,该容器在片段内膨胀。这些卡片视图在列表项之间有很大的差距。所有的 recyclerviews 似乎都有同样的问题。
recyclerview容器的代码如下:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<android.support.v7.widget.RecyclerView
android:id="@+id/rv"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:scrollbars="vertical" />
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/progressBar"
android:layout_centerInParent="true"
android:layout_marginTop="20dp"
android:background="@drawable/ProgressBarStyle"
android:visibility="invisible" />
</RelativeLayout>
列表项的代码如下:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="0dp">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardPreventCornerOverlap="false"
app:cardUseCompatPadding="false"
android:id="@+id/cv">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp">
<refractored.controls.CircleImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:id="@+id/person_photo"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginRight="16dp"
android:src="@drawable/profile2" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/person_name"
android:layout_toRightOf="@+id/person_photo"
android:layout_marginTop="10dp"
android:textStyle="bold"
android:layout_alignParentTop="false"
android:textSize="20sp" />
</RelativeLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
更新前一切正常。我不知道为什么更新搞砸了一切。这就是列表项现在的显示方式。您必须上下滚动才能查看其他项目。
尝试将 listItem xml 中的根 LinearLayout
的高度设置为 wrap_content
。
我刚刚将 Android 支持库的新更新安装到版本 23.2.1.0,当我 运行 项目时,我遇到了一个以前没有的问题。我正在使用显示在 recyclerview 容器内的卡片视图,该容器在片段内膨胀。这些卡片视图在列表项之间有很大的差距。所有的 recyclerviews 似乎都有同样的问题。
recyclerview容器的代码如下:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<android.support.v7.widget.RecyclerView
android:id="@+id/rv"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:scrollbars="vertical" />
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/progressBar"
android:layout_centerInParent="true"
android:layout_marginTop="20dp"
android:background="@drawable/ProgressBarStyle"
android:visibility="invisible" />
</RelativeLayout>
列表项的代码如下:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="0dp">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardPreventCornerOverlap="false"
app:cardUseCompatPadding="false"
android:id="@+id/cv">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp">
<refractored.controls.CircleImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:id="@+id/person_photo"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginRight="16dp"
android:src="@drawable/profile2" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/person_name"
android:layout_toRightOf="@+id/person_photo"
android:layout_marginTop="10dp"
android:textStyle="bold"
android:layout_alignParentTop="false"
android:textSize="20sp" />
</RelativeLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
更新前一切正常。我不知道为什么更新搞砸了一切。这就是列表项现在的显示方式。您必须上下滚动才能查看其他项目。
尝试将 listItem xml 中的根 LinearLayout
的高度设置为 wrap_content
。