0

J'ai essayé d'utiliser la disposition Coordinateur pour créer une barre d'outils de réduction et inclure une disposition à l'aide de la vue Recycleur, mais la barre d'outils ne s'effondre pas. Quelqu'un pourrait-il souligner ce que je fais mal? Merci.Utilisation de la mise en page du coordinateur pour la création de la barre d'outils et de la vue Recycleur

Voici le code: activity_main.xml

<?xml version="1.0" encoding="utf-8"?> 
<android.support.design.widget.CoordinatorLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:fitsSystemWindows="true"> 
<android.support.design.widget.AppBarLayout 
    android:id="@+id/appbar" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:fitsSystemWindows="true" 
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" 
    android:elevation="4dp"> 


    <android.support.design.widget.CollapsingToolbarLayout 
     android:id="@+id/collapsing_toolbar" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:fitsSystemWindows="true" 
     app:contentScrim="?attr/colorPrimary" 
     app:layout_scrollFlags="scroll|exitUntilCollapsed"> 

     <ImageView 
      android:id="@+id/header" 
      android:layout_width="match_parent" 
      android:layout_height="100dp" 
      android:background="#205052" 
      android:fitsSystemWindows="true" 
      android:scaleType="centerCrop" 
      app:layout_collapseMode="parallax" /> 
     <android.support.v7.widget.Toolbar 
      android:id="@+id/anim_toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="?attr/actionBarSize" 
      app:layout_collapseMode="parallax" 
      app:popupTheme="@style/ThemeOverlay.AppCompat.Light"> 

      <TextView 
       android:id="@+id/toolbar_title" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:fontFamily="sans-serif-light" 
       android:text="hello" 
       android:gravity="center" 
       android:singleLine="true" 
       android:textColor="@android:color/white" 
       android:textSize="18sp" /> 
     </android.support.v7.widget.Toolbar> 
    </android.support.design.widget.CollapsingToolbarLayout> 
</android.support.design.widget.AppBarLayout> 


<android.support.v4.widget.NestedScrollView 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:layout_gravity = "fill_vertical" 
android:layout_marginBott`enter code here`om="?attr/actionBarSize" 
app:layout_behavior = "@string/appbar_scrolling_view_behavior"> 
<include layout="@layout/recycler"/> 

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

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

recycler.xml

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
android:orientation="vertical" 
android:layout_width="match_parent" 
android:layout_height="match_parent"> 

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

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


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

Répondre

0

Essayez le réglage android:layout_height="wrap_content" pour <android.support.design.widget.CollapsingToolbarLayout />