2017-06-03 86 views
0

我在我的活動中有2個recyclerviews第一個是水平滾動的,第二個是垂直滾動的。 (XML代碼如下) 但滾動不順暢。在活動中滾動多個回收站視圖。 (如何使其平滑)

<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> 

我使用

setNestedScrollingEnabled(false); 

兩個回收視圖。

任何想法用平滑滾動來實現這一點?

回答

0

我如何解決這個問題是通過使用單個Recycler視圖而不是兩個,並設置其他第一個回收視圖回收視圖作爲它的第一個項目。 現在它工作完美,滾動順利。

0

更改ScrollViewNestedScrollView

爲了這個工作,你需要有RecyclerView與高度wrap_contentNestedScrollView,你需要設置recyclerView.setNestedScrollingEnabled(false)從代碼。

+0

雖然此代碼可能會回答問題,但提供有關_how_和/或_why_的附加[上下文](https://meta.stackexchange.com/q/114762)可以解決問題,從而提高答案的長期價值。請記住,你正在爲將來的讀者回答這個問題,而不僅僅是現在問的人!請[編輯](http://stackoverflow.com/posts/44348534/edit)您的答案添加一個解釋,並指出適用的限制和假設。 –