2016-09-11 2 views
1

Recycler-Ansicht scrollt ohne kollabierende Toobar. Das ist mein Hauptlayout.Recycler-Ansicht scrollt ohne kollabierende Toobar

<CoordinatorLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:id="@+id/coordinator" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <android.support.design.widget.AppBarLayout 
     android:id="@+id/appbar" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:animateLayoutChanges="true" 
     > 

     <android.support.design.widget.CollapsingToolbarLayout 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:id="@+id/collapp_bar" 
      app:layout_scrollFlags="scroll|exitUntilCollapsed" 
      > 
      <View 
       android:id="@+id/image" 
       android:layout_width="fill_parent" 
       android:layout_height="220dp" 
       app:layout_collapseMode="parallax" 
       android:background="@android:color/transparent" 
       /> 
      <include layout="@layout/custom_toolbar" /> 
      <android.support.v4.widget.NestedScrollView 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       app:layout_collapseMode="parallax" 
       android:layout_gravity="bottom" 
       android:id="@+id/nestedScrollView" 
       android:layout_marginBottom="10dp" 
       > 
      <android.support.v7.widget.RecyclerView 
       android:layout_width="match_parent" 
       android:id="@+id/recyclerView" 
       android:layout_height="wrap_content" 
       android:orientation="horizontal" /> 
      </android.support.v4.widget.NestedScrollView> 
     </android.support.design.widget.CollapsingToolbarLayout> 

    </android.support.design.widget.AppBarLayout> 
    <ViewPager 
     android:id="@+id/viewpager" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:background="#f4f4f4" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior" 
     /> 


<android.support.design.widget.TabLayout 
     android:id="@+id/tab_layout" 
     android:layout_width="fill_parent" 
     android:layout_height="50dp" 
     app:tabMode="fixed" 
     app:tabGravity="fill" 
     app:tabTextColor="@color/gray" 

     app:tabSelectedTextColor="@color/selected_text_color" 
     app:tabIndicatorColor="@color/more_comment_color" 
     android:background="@android:color/background_light" 
     android:layout_gravity="bottom" 

     /> 
    <ImageView 
     android:id="@+id/imageView" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="bottom|center_horizontal" 
     app:layout_anchor="@id/tab_layout" 

     app:layout_anchorGravity="bottom|center" 
     android:layout_marginTop="-20dp" 
     /> 

</CoordinatorLayout> 

Dies ist das Layout, die ich in View Pager

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:id="@+id/container" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@android:color/white"> 

    <android.support.v4.widget.SwipeRefreshLayout 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:id="@+id/swipe" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     > 


     <android.support.v7.widget.RecyclerView 
      xmlns:android="http://schemas.android.com/apk/res/android" 
      android:id="@+id/recyler_view" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:background="@color/bg_listview" /></android.support.v4.widget.SwipeRefreshLayout> 
    </RelativeLayout> 

Meine Recycler Ansicht scrollt, auch sometimes.Alsothe Scrollen ohne zusammenzubrechen Symbolleiste Pager nicht smooth.In recyClerView Sicht i a haben bin Einrichtung Header-Element und dann die Liste der Elemente. Manchmal bleibt es bei Kopfzeile oben stecken und muss es herunterziehen.

Antwort

0

Für jeden RecyclerView, die hat eine Rolle im übergeordneten (wie Scroll oder NestedScrollView) ist, sollten Sie verschachtelte Scrollen wie folgt deaktivieren:

yourRecyclerView.setNestedScrollingEnabled(false); 

Für Ihre Glättung Problem scheint es, dass ein Fehler dort mit AppBarLayout ist und dort sind einige Bibliotheken, um das zu beheben. Eine, die ich kenne, aber ich nie benutzt habe, ist: https://github.com/henrytao-me/smooth-app-bar-layout

Verwandte Themen