0

J'ai un problème pour faire défiler mon recyclerview. J'essaie d'obtenir l'effet d'image de parallaxe donc j'ai trouvé this tutoriel et a adopté cela. Après cela, j'ai remarqué que les vues recycleur dans mon viewpager ne défilaient plus.Problèmes de défilement Android - CoordinatorLayout + CollapsingToolBarLayout + Afficher Pager + Recycler Afficher

J'ai examiné quelques solutions: J'ai trouvé this, mais rien ne semble fonctionner.

Ceci est mon XML ci-dessous:

<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" 
> 
    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="@dimen/rel_layout_size" 
     android:background="@android:color/white" 
     android:orientation="horizontal" 
     android:focusable="true" 
     > 

     <ImageView 
      android:id="@+id/search_icon" 
      android:layout_width="@dimen/icons_size" 
      android:layout_height="@dimen/icons_size" 
      android:src="@drawable/search" 
      android:layout_alignParentEnd="true" 
      android:layout_marginTop="10dp" 
      android:layout_marginBottom="10dp" 
      android:layout_marginRight="15dp" 
      android:layout_marginLeft="10dp" 
      /> 

     <ImageView 
      android:id="@+id/like_icon" 
      android:layout_width="@dimen/icons_size" 
      android:layout_height="@dimen/icons_size" 
      android:src="@drawable/like" 
      android:layout_toStartOf="@id/search_icon" 
      android:layout_marginTop="10dp" 
      android:layout_marginBottom="10dp" 
      /> 

    </RelativeLayout> 
    <android.support.design.widget.CoordinatorLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:fitsSystemWindows="true" 
     app:contentScrim="@android:color/white" 
    > 

    <android.support.design.widget.AppBarLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:background="@android:color/white" 
     android:theme="@style/AppTheme.LightActionBar" 
     app:contentScrim="@android:color/white" 
     android:fitsSystemWindows="true" 
    > 

     <android.support.design.widget.CollapsingToolbarLayout 
       android:id="@+id/htab_collapse_toolbar" 
       android:layout_width="match_parent" 
       android:layout_height="200dp" 
       android:fitsSystemWindows="true" 
       app:contentScrim="@android:color/white" 
       app:layout_scrollFlags="scroll|exitUntilCollapsed|snap" 
       app:titleEnabled="false"> 



       <ImageView 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:background="@drawable/home" 
        android:fitsSystemWindows="true" 
        android:scaleType="centerCrop" 
        app:layout_collapseMode="parallax" 
        app:layout_collapseParallaxMultiplier="0.75" 
        /> 

       <View 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:alpha="0.1" 
        android:background="@android:color/white" 
        android:fitsSystemWindows="true"/> 



       <android.support.v7.widget.Toolbar 
        android:layout_width="match_parent" 
        android:layout_height="20dp" 
        android:layout_gravity="top" 
        app:layout_collapseMode="pin" 
        app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/> 



       <android.support.design.widget.TabLayout 
        android:id="@+id/tabLayout" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:layout_gravity="bottom" 
        android:background="@android:color/white" 
        app:tabIndicatorColor="@android:color/black" 
        app:tabSelectedTextColor="@android:color/black" 
        app:tabTextColor="@android:color/darker_gray"/> 

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

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

     <xyz.santeri.wvp.WrappingViewPager 
      android:id="@+id/pager" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:background="@android:color/white" 
      app:layout_behavior="@string/appbar_scrolling_view_behavior" 
     /> 

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

et un fragment XML exemple est illustré ci-dessous:

<android.support.v4.widget.NestedScrollView 
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:fillViewport="true" 
android:layout_gravity="fill_vertical" 
app:layout_behavior="@string/appbar_scrolling_view_behavior" 
> 

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

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

Répondre

0

J'ai trouvé plus tard la solution sur. Il s'avère que le RelativeLayout le corrige. Cela pourrait aider quelqu'un

<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" > 

<RelativeLayout 
    android:id="@+id/search_bar" 
    android:layout_width="match_parent" 
    android:layout_height="@dimen/rel_layout_size" 
    android:background="@android:color/white" 
    android:orientation="horizontal" 
    android:layout_alignParentTop="true" 
    android:focusable="true" 
    > 

    <ImageView 
     android:id="@+id/search_icon" 
     android:layout_width="@dimen/icons_size" 
     android:layout_height="@dimen/icons_size" 
     android:src="@drawable/search" 
     android:layout_alignParentEnd="true" 
     android:layout_marginTop="10dp" 
     android:layout_marginBottom="10dp" 
     android:layout_marginRight="15dp" 
     android:layout_marginLeft="10dp" 
     /> 

    <ImageView 
     android:id="@+id/like_icon" 
     android:layout_width="@dimen/icons_size" 
     android:layout_height="@dimen/icons_size" 
     android:src="@drawable/like" 
     android:layout_toStartOf="@id/search_icon" 
     android:layout_marginTop="10dp" 
     android:layout_marginBottom="10dp" 
     /> 

</RelativeLayout> 

    <android.support.design.widget.CoordinatorLayout 
     android:layout_width="match_parent" 
     android:layout_below="@+id/search_bar" 
     android:layout_height="match_parent" 
     android:fitsSystemWindows="true" 
     app:contentScrim="@android:color/white" 
    > 

<android.support.design.widget.AppBarLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:background="@android:color/white" 
    android:theme="@style/AppTheme.LightActionBar" 
    app:contentScrim="@android:color/white" 
    android:fitsSystemWindows="true" 
    > 
    <!--android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"--> 



    <android.support.design.widget.CollapsingToolbarLayout 
     android:id="@+id/htab_collapse_toolbar" 
     android:layout_width="match_parent" 
     android:layout_height="200dp" 
     android:fitsSystemWindows="true" 
     app:contentScrim="@android:color/white" 
     app:layout_scrollFlags="scroll|exitUntilCollapsed|snap" 
     app:titleEnabled="false"> 



     <ImageView 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:background="@drawable/home" 
      android:fitsSystemWindows="true" 
      android:scaleType="centerCrop" 
      app:layout_collapseMode="parallax" 
      app:layout_collapseParallaxMultiplier="0.75" 
      /> 

     <View 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:alpha="0.1" 
      android:background="@android:color/white" 
      android:fitsSystemWindows="true"/> 



     <android.support.v7.widget.Toolbar 
      android:layout_width="match_parent" 
      android:layout_height="20dp" 
      android:layout_gravity="top" 
      app:layout_collapseMode="pin" 
      app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/> 
     <!--android:layout_height="?attr/actionBarSize"--> 


     <android.support.design.widget.TabLayout 
      android:id="@+id/tabLayout" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_gravity="bottom" 
      android:background="@android:color/white" 
      app:tabIndicatorColor="@android:color/black" 
      app:tabSelectedTextColor="@android:color/black" 
      app:tabTextColor="@android:color/darker_gray" 
      android:fillViewport="false" /> 

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

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="1dp" 
     android:background="@android:color/darker_gray"/> 

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

     <!--<xyz.santeri.wvp.WrappingViewPager--> 
     <android.support.v4.view.ViewPager 
      android:id="@+id/pager" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:background="@android:color/white" 
      app:layout_behavior="@string/appbar_scrolling_view_behavior" 
     /> 
    </android.support.design.widget.CoordinatorLayout>