0

NestedScrollView를 사용하여 스크롤 할 때 툴바를 숨기지 만, 그 안에 recyclerView를 넣으면 툴바가 스크롤에 숨기지 않고 가능한 한 answer를 사용할 수 있지만 노하우는 늘었고 특히 나는 recyclerView.setNestedScrollingEnabled(false);을 사용했습니다. 여기 scroll에서 toolbar를 숨기는 방법 NestedScrollView 내부에서 recyclerView를 사용하는 경우

내 코드입니다 :

<android.support.v4.widget.NestedScrollView 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" 

    app:layout_behavior="@string/appbar_scrolling_view_behavior"> 

<RelativeLayout 

    android:layout_width="match_parent" 
    android:background="#fff" 
    android:layout_height="wrap_content" 
    > 



    <android.support.v7.widget.RecyclerView 



     android:id="@+id/recyclerView" 
     android:background="#fafafa" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_centerInParent="true" /> 

    <ProgressBar 
     android:id="@+id/progressBar1" 

     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_centerInParent="true" /> 

</RelativeLayout> 

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

--- 편집 -----------

<?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/DrawerLayout" 

    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:elevation="7dp"> 
    <include 
     android:id="@+id/includeAppBar" 
     layout="@layout/app_bar_navigation_drawer" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" /> 


    <android.support.v7.widget.RecyclerView 
     android:id="@+id/RecyclerView" 
     android:layout_width="320dp" 
     android:layout_height="match_parent" 
     android:layout_gravity="left" 

     android:background="#ffffff" 
     android:scrollbars="vertical"> 

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

---- 편집 2 ----

<?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.support.design.widget.AppBarLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 

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


     <!-- our tablayout to display tabs --> 
     <android.support.design.widget.TabLayout 
      android:id="@+id/tabLayout" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:background="#fff" 
      app:tabTextColor="#a6a2a2" 
      app:tabSelectedTextColor="#0099ff" 
      app:tabIndicatorColor="#0099ff" 


      android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"/> 
    </android.support.design.widget.AppBarLayout> 
    <!-- View pager to swipe views --> 
    <android.support.v4.view.ViewPager 
     android:id="@+id/pager" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior" 
     android:layout_width="match_parent" 
     android:layout_height="fill_parent"/> 






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

안녕하세요, 툴바로 xml 코드를 공유 할 수 있습니까 – Cochi

+0

안녕하세요 내 편집 질문을 참조하십시오. –

+0

app_bar_navigation_drawer 레이아웃도 표시 할 수 있습니까? – Cochi

답변

0
당신은 당신의 AppBarLayout이 attibute를 추가,이 시도 할 수

:

app:layout_scrollFlags="scroll|exitUntilCollapsed"

편집 :

변경뿐만 아니라 아래와 같이 코드 :

<?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/DrawerLayout" 

    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:elevation="7dp"> 
    <include 
     android:id="@+id/includeAppBar" 
     layout="@layout/app_bar_navigation_drawer" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" /> 


    <android.support.v7.widget.RecyclerView 
     android:id="@+id/RecyclerView" 
     android:layout_width="320dp" 
     android:layout_height="match_parent" 
     android:layout_gravity="left" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior" // new attibute 
     android:background="#ffffff" 
     android:scrollbars="vertical"> 

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

희망이 도움이 .

죄송합니다.

+0

그것이 작동하지 않는다면 –

+0

내 편집이 도움이되는지 확인하십시오. – Cochi