Antwort

0

Ihre RecyclerView im Coordinatorlayout sein sollten, die Animation und verwenden Sie einen NestedScrollView als Elternteil für Ihre RecyclerView auszuführen:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
android:id="@+id/activity_main" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
tools:context="realup.ir.teacher.MainActivity"> 

<android.support.design.widget.CoordinatorLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:id="@+id/header"> 

    <android.support.design.widget.AppBarLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:id="@+id/app_bar_head"> 
     <android.support.design.widget.CollapsingToolbarLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      app:layout_scrollFlags="scroll|enterAlways" 
      android:id="@+id/collapse_toolbar"> 

      <ImageView 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:adjustViewBounds="true" 
       android:scaleType="centerCrop" 
       android:src="@drawable/realup" 
       android:id="@+id/header_image"/> 


     </android.support.design.widget.CollapsingToolbarLayout> 

    </android.support.design.widget.AppBarLayout> 

    <android.support.v4.widget.NestedScrollView 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      app:layout_behavior="@string/appbar_scrolling_view_behavior"/> 

     <android.support.v7.widget.RecyclerView 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:id="@+id/recycle"/> 

    </android.support.v4.widget.NestedScrollView> 

</android.support.design.widget.CoordinatorLayout> 
</RelativeLayout> 

Um ein glattes Scroll effet in Ihrem Code hinzufügen zu erhalten:

RecyclerView recyclerView = (RecyclerView)findViewById(R.id.recycle); 
recyclerView.setNestedScrollingEnabled(false); 

Hoffe das hilft.

Entschuldigung für mein Englisch.

+0

Vielen Dank, Entwickler;) –

+0

Gern geschehen :) Sie können das relative Layout entfernen, wenn Sie keine Notwendigkeit haben – Cochi

0

Nehmen Sie CoordinatorLayout als übergeordnetes Layout und setzen Sie RecyclerView in FrameLayout;

<android.support.design.widget.CoordinatorLayout 
    android:id="@+id/coordinator" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <android.support.design.widget.AppBarLayout 
     android:id="@+id/appbar" 
     android:background="#e7e5e5" 
     android:layout_marginLeft="-20dp" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 

     <android.support.design.widget.CollapsingToolbarLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     app:layout_scrollFlags="scroll|enterAlways" 
     android:id="@+id/collapse_toolbar"> 

     <ImageView 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:adjustViewBounds="true" 
      android:scaleType="centerCrop" 
      android:src="@drawable/realup" 
      android:id="@+id/header_image"/> 


    </android.support.design.widget.CollapsingToolbarLayout> 
    </android.support.design.widget.AppBarLayout> 

    <FrameLayout 
     android:id="@+id/dashboard_content" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior"> 

     <android.support.v7.widget.RecyclerView 
      android:id="@+id/task_list" 
      android:scrollbars="vertical" 
      android:paddingBottom="85dp" 
      android:layout_marginLeft="10dp" 
      android:layout_marginRight="10dp" 
      app:layout_behavior="@string/appbar_scrolling_view_behavior" 
      android:layout_marginTop="10dp" 
      android:clipToPadding="false" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content"> 

     </android.support.v7.widget.RecyclerView> 

     </FrameLayout> 
</android.support.design.widget.CoordinatorLayout> 
+0

meinst du, ich sollte das Relative Layout als Eltern für den gesamten Bildschirm löschen? –

+0

Kommentieren Sie Ihre ganze XML und setzen Sie diese und überprüfen Sie, was passieren –

+0

setzen Sie Ihre eigene Recyclerview ID in xml –

Verwandte Themen