2017-07-12 3 views
1

はxmlファイルがRecyclerViewは、そのアイテムの高さはここで

RecyclerviewFragmentある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> 

これは次のようになります。

item_height_wrap_content

ご覧のとおり、私がスクロールすると、読み込みが高速でスムーズになりません。一部の項目のスクロールを停止します。
また、上にスクロールすると、直接上の項目にジャンプします。以下は

は、私が "match_parent"Recyclerviewの項目の(ここでは CardView)の高さにすることによって達成することができる午前 RecyclerViewの完璧なスムーズで高速スクロール効果、です。

item_height_match_parent

しかし、これは、私はリストが見えるようにする方法はありません。リストには可変長のイメージがあり、その間に空白はありません。

GlideApp.with(mContext) 
      .load(url) 
      .placeholder(R.color.placeholder) 
      .into(holder.photo); 

RecyclerViewスクロールスムーズとアップスクロールに最初の項目にジャンプしません:私はイメージをロードするためにGlideを使用して、そしてGlideを通じてプレースホルダを追加してい

答えて

2

はそれを修正しました。

私は実際にはRecyclerViewがこのように動作する理由を知りませんでしたが、修正されましたが、

関連する問題