1
はxmlファイルがRecyclerViewは、そのアイテムの高さはここで
Recyclerview
とFragment
あるwrap_contentされたときまでスクロールしたとき先頭に直接ジャンプ:
<?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>
これは次のようになります。
ご覧のとおり、私がスクロールすると、読み込みが高速でスムーズになりません。一部の項目のスクロールを停止します。
また、上にスクロールすると、直接上の項目にジャンプします。以下は
"match_parent"
に
Recyclerview
の項目の(ここでは
CardView
)の高さにすることによって達成することができる午前
RecyclerView
の完璧なスムーズで高速スクロール効果、です。
しかし、これは、私はリストが見えるようにする方法はありません。リストには可変長のイメージがあり、その間に空白はありません。
GlideApp.with(mContext)
.load(url)
.placeholder(R.color.placeholder)
.into(holder.photo);
今RecyclerView
スクロールスムーズとアップスクロールに最初の項目にジャンプしません:私はイメージをロードするためにGlide
を使用して、そしてGlide
を通じてプレースホルダを追加してい