2016-08-02 10 views
1

この件に関して多くの質問がありましたが、私の助けにはならなかったもののどれも(私はほとんどのものを試しましたが、まだそれを動作させることはできません)。私のレイアウトは以下の通りです:DrawerLayout、ツールバー、およびRecyclerViewを備えたViewPagerを使用してレイアウト内のツールバーを折りたたむ方法は?

<?xml version="1.0" encoding="utf-8"?> 

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:id="@+id/drawer_layout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:background="@null" 
     android:orientation="vertical"> 

     <android.support.design.widget.CoordinatorLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content"> 

      <android.support.design.widget.AppBarLayout 
       android:id="@+id/toolbar_wrapper" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:fitsSystemWindows="true"> 

       <android.support.v7.widget.Toolbar 
        android:id="@+id/toolbar" 
        android:layout_width="match_parent" 
        android:layout_height="?attr/actionBarSize" 
        android:background="?attr/colorPrimary" 
        app:layout_scrollFlags="scroll|enterAlways" 
        app:popupTheme="@style/ThemeOverlay.AppCompat.Light" 
        app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" /> 

       <com.ogaclejapan.smarttablayout.SmartTabLayout 
        android:id="@+id/tabs" 
        android:layout_width="match_parent" 
        android:layout_height="40dip" 
        android:layout_weight="1" 
        android:clickable="true" 
        app:stl_defaultTabTextAllCaps="true" 
        app:stl_defaultTabTextColor="#000" 
        app:stl_defaultTabTextHorizontalPadding="0dip" 
        app:stl_defaultTabTextMinWidth="0dp" 
        app:stl_defaultTabTextSize="14sp" 
        app:stl_distributeEvenly="true" 
        app:stl_drawDecorationAfterTab="true" 
        app:stl_indicatorColor="@android:color/white" 
        app:stl_indicatorGravity="bottom" 
        app:stl_indicatorInFront="false" 
        app:stl_indicatorInterpolation="smart" 
        app:stl_indicatorThickness="2dp" 
        app:stl_overlineThickness="0dp" 
        app:stl_titleOffset="24dp" 
        app:stl_underlineThickness="0dp" /> 
      </android.support.design.widget.AppBarLayout> 
     </android.support.design.widget.CoordinatorLayout> 

     <android.support.v4.view.ViewPager 
      android:id="@+id/viewpager" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:background="@null" 
      app:layout_behavior="@string/appbar_scrolling_view_behavior" /> 
    </LinearLayout> 

    <android.support.design.widget.NavigationView 
     android:id="@+id/nav_view" 
     android:layout_width="wrap_content" 
     android:layout_height="match_parent" 
     android:layout_gravity="start" 
     android:fitsSystemWindows="true" 
     app:headerLayout="@layout/rsc_homepage_drawer_layout_content" 
     app:menu="@menu/drawer_itens" /> 
</android.support.v4.widget.DrawerLayout> 

各フラグメントには1つのRecyclerViewがあります。何が問題ですか? RecyclerViewをスクロールすると、何も起こりません。ツールバーをスクロールすると、それが隠れて、RecyclerViewは元の位置に残ります。どんな助けもありがとう!

UPDATE

以下

あるすべての私の断片:

フラグメント1

<RelativeLayout> 
    <RelativeLayout> 
     <android.support.v7.widget.CardView> 
      <LinearLayout> 
       <TextView/> 
       <TextView /> 
      </LinearLayout> 
     </android.support.v7.widget.CardView> 

     <com.mikhaellopez.circularimageview.CircularImageView/> 
    </RelativeLayout> 

    <LinearLayout> 
     <TextView /> 
     <TextView /> 
     <TextView /> 
    </LinearLayout> 
</RelativeLayout> 

<android.support.v7.widget.CardView> 
    <TextView/> 
</android.support.v7.widget.CardView> 

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

フラグメント2

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:card_view="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@null"> 

.... 

<RelativeLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent"> 

      <android.support.v7.widget.CardView 
       android:id="@+id/not_results_found_wrapper" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_centerHorizontal="true" 
       android:alpha="0.95" 
       android:elevation="4dip" 
       android:visibility="gone" 
       card_view:cardBackgroundColor="@android:color/white" 
       card_view:cardCornerRadius="5dp" 
       card_view:cardUseCompatPadding="true"> 

       <TextView 
        android:id="@+id/not_results_found" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_centerHorizontal="true" 
        android:padding="10dip" 
        android:text="@string/rsc_search_friends_no_results_founds" 
        android:textColor="@color/colorPrimaryDark" 
        android:textSize="@dimen/textH3" 
        android:textStyle="bold" /> 
      </android.support.v7.widget.CardView> 

      <android.support.v7.widget.RecyclerView 
       android:id="@+id/result" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:layout_below="@+id/not_results_found_wrapper" 
       android:layout_marginEnd="10dip" 
       android:layout_marginStart="10dip" 
       android:layout_marginTop="5dip" 
       android:overScrollMode="never" /> 
     </RelativeLayout> 
</ScrollView> 

断片3

<?xml version="1.0" encoding="utf-8"?> 

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:card_view="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@android:color/transparent" 
    android:orientation="vertical"> 

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

    <android.support.v7.widget.CardView 
     android:id="@+id/msg_wrapper" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_centerInParent="true" 
     android:layout_margin="30dip" 
     android:alpha="0.95" 
     android:elevation="4dip" 
     card_view:cardBackgroundColor="@android:color/white" 
     card_view:cardCornerRadius="5dp" 
     card_view:cardUseCompatPadding="true"> 

     <TextView 
      android:id="@+id/results_not_found" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_centerInParent="true" 
      android:gravity="center" 
      android:layout_margin="15dip" 
      android:text="@string/frag_chats_no_chat_use" 
      android:textAlignment="center" 
      android:textColor="@color/colorPrimaryDark" 
      android:textSize="@dimen/textH2" 
      android:textStyle="bold" /> 
    </android.support.v7.widget.CardView> 
</RelativeLayout> 

断片4

<?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:fab="http://schemas.android.com/apk/res-auto" 
    android:id="@+id/main_content" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@android:color/transparent"> 

    <android.support.v7.widget.RecyclerView 
     android:id="@+id/games" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_below="@+id/toolbar_wrapper" 
     android:overScrollMode="never"/> 

    <com.melnykov.fab.FloatingActionButton 
     android:id="@+id/add_game" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="bottom|right" 
     android:layout_margin="16dip" 
     android:clickable="true" 
     android:src="@drawable/ic_plus_white_24dp" 
     app:borderWidth="0dp" 
     app:elevation="4dp" 
     app:layout_anchor="@id/games" 
     app:layout_anchorGravity="bottom|right|end" 
     fab:fab_colorNormal="@color/colorPrimary" 
     fab:fab_colorPressed="@color/colorPrimaryDark" /> 
</android.support.design.widget.CoordinatorLayout> 
+0

'アプリを削除:' ViewPager'し、それから、あなたのフラグメント(RecyclerViewの親ビュー)のそれぞれの親にlayout_behavior = "@文字列/ appbar_scrolling_view_behavior" '。 –

+0

同じこと。私がちょっと気付いたのは、私のフラグメントのうちの2つが親コンポーネントによってScrollViewともう1つのCoordinatorLayoutを持っているということです。問題ありますか? –

+0

はい、スクロールビューはツールバーの折りたたみを制限します。あなたのリサイクルビューには 'app:layout_behavior =" @文字列/ appbar_scrolling_view_behavior "'またはリダイレクタービューの上に 'layout_behaviour'フラグを持つリニアまたは相対レイアウトを指定してください。 –

答えて

1

あなたRecyclerViewNestedScrollView中に入れてみてください。このような

何か:

<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" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior"> 

<android.support.v7.widget.RecyclerView 
    android:id="@+id/my_recycler_view" 
    android:scrollbars="vertical" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"/> 
+0

Unfortunatelly何も変更されていません –

関連する問題