2017-06-03 5 views
0

私の活動には2つのrecyclerviewsがあります。第1のものは水平にスクロール可能で、第2のものは垂直スクロール可能です。 (下のXMLコード) しかし、スクロールがスムーズではありません。私は両方のリサイクルビューのためにアクティビティ内の複数のリサイクラビューのスクロール。 (滑らかにする方法)

setNestedScrollingEnabled(false); 

を使用

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/ll1" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="#eeeeee" 
    android:clickable="true" 
    > 
    <ProgressBar 
     android:id="@+id/progressBarCircularIndetermininatesearch" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:indeterminateTintMode="src_atop" 
     android:indeterminateTint="#f44336" 
     android:layout_centerInParent="true"/> 

    <ScrollView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_above="@+id/progressbacklin" 
     android:scrollbars="none" 
     > 
     <RelativeLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content"> 
    <android.support.v7.widget.RecyclerView 
     android:id="@+id/videolist" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginLeft="2dp" 
     android:layout_marginRight="2dp" 
     android:layout_alignParentTop="true" 
     android:scrollbars="none" 
     /> 


    <android.support.v7.widget.RecyclerView 
     android:id="@+id/list" 
     android:layout_below="@+id/videolist" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginLeft="2dp" 
     android:layout_marginRight="2dp" 
     android:scrollbars="none" 
     /> 
     </RelativeLayout> 
</ScrollView> 
    <LinearLayout 
     android:id="@+id/progressbacklin" 
     android:layout_above="@+id/adViewsearch" 
     android:layout_width="48dp" 
     android:layout_height="48dp" 
     android:layout_marginBottom="90dp" 
     android:layout_marginTop="5dp" 
     android:background="@drawable/white" 
     android:gravity="center" 
     android:layout_centerHorizontal="true" 
     android:layout_alignParentBottom="true" 
     > 
     <ProgressBar 
      android:id="@+id/progressBarCircularIndetermininate" 
      android:layout_width="24dp" 
      android:layout_height="24dp" 
      android:indeterminateTintMode="src_atop" 
      android:indeterminateTint="#f44336" 
      android:layout_centerInParent="true"/> 
    </LinearLayout> 
    <com.google.android.gms.ads.AdView 
     xmlns:ads="http://schemas.android.com/apk/res-auto" 
     android:id="@+id/adViewsearch" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     ads:adSize="SMART_BANNER" 
     ads:adUnitId="@string/banner_ad_unit_id" /> 

</RelativeLayout> 

滑らかなスクロールでこれを実装する方法はありますか?

答えて

0

2つではなく1つのRecyclerビューを使用して、もう1つのリサイクルビュー(問題の第1のリサイクルビュー)リサイクルビューを最初のアイテムとして設定します。 これは完璧に動作し、スムーズにスクロールします。

0

ScrollViewからNestedScrollViewに変更してください。

これが機能するためには、NestedScrollViewの内側に高さwrap_contentRecyclerViewを持っている必要があり、あなたがコードからrecyclerView.setNestedScrollingEnabled(false)を設定する必要があります。

+0

このコードは質問に答えるかもしれませんが、_how_および/または_why_に関する追加の[context](https://meta.stackexchange.com/q/114762)を提供することで、問題を解決して回答の長期的価値を向上させることができます。あなたが今質問している人だけでなく、将来読者のための質問に答えていることを忘れないでください!あなたの答えを説明し、何が制限や前提条件が適用されるかを示すためにあなたの答えを編集してください(http://stackoverflow.com/posts/44348534/edit)。 –

関連する問題