【发布时间】:2017-07-12 17:23:15
【问题描述】:
这里是xml文件
Fragment 和 Recyclerview:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/list_photos"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.photos.PhotosFragment"
tools:listItem="@layout/card_photo">
</android.support.v7.widget.RecyclerView>
上面Recyclerview中每一项的布局
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/card_photo"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/photo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:adjustViewBounds="true"
android:scaleType="fitCenter"
tools:src="@drawable/placeholder_photo_item" />
</android.support.v7.widget.CardView>
它看起来像这样:
如您所见,当我滚动时,它不会快速流畅地加载。它会在某些项目上停止滚动。
另外,当我向上滚动时,它会直接跳转到顶部。
下面是RecyclerView 的完美平滑和快速滚动效果,我可以通过将Recyclerview 的项目(此处为CardView)的高度设置为"match_parent" 来实现。
但这不是我希望列表的样子。该列表应该包含可变长度的图像,它们之间没有空格。
【问题讨论】:
标签: android android-layout android-recyclerview