2017-03-26 3 views
0

많은 시간 전에이 질문을 받았지만 여전히 작동하지 못한다는 것을 알고 있습니다. app : layout_scrollFlags = "scroll | enterAlways" 매개 변수가 있지만 중첩과 관련이 있다고 생각합니다. 아래 나의 XML 파일 :스크롤 도구 모음 숨기기

activity_main.xml는

<?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" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:background="@color/colorBG" 
    android:fitsSystemWindows="true" 
    android:id="@+id/mDrawerLayout" 
    android:layout_height="match_parent" 
    android:layout_width="match_parent" 
    tools:context=".MainActivity"> 

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

    <LinearLayout 
     android:fitsSystemWindows="true" 
     android:layout_height="match_parent" 
     android:layout_width="match_parent" 
     android:orientation="vertical"> 

     <!-- App Bar--> 
     <android.support.v7.widget.Toolbar 
      android:background="@color/colorPrimary" 
      android:id="@+id/mToolbar" 
      android:layout_height="50dp" 
      android:layout_width="match_parent" 
      android:minHeight="?attr/actionBarSize" 
      android:theme="@style/AppTheme.Toolbar" 
      app:layout_scrollFlags="scroll|enterAlways"/> 

     <FrameLayout 
      android:id="@+id/containerView" 
      android:layout_height="match_parent" 
      android:layout_width="match_parent"> 
     </FrameLayout> 

    </LinearLayout> 

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

<android.support.design.widget.NavigationView 
    android:background="@color/colorPrimaryLight" 
    android:id="@+id/mNavigationView" 
    android:layout_gravity="start" 
    android:layout_height="match_parent" 
    android:layout_width="wrap_content" 
    app:headerLayout="@layout/header" 
    app:itemBackground="@color/colorPrimaryLight" 
    app:itemIconTint="@color/colorText" 
    app:itemTextColor="@color/colorText" 
    app:menu="@menu/drawer"/> 

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

답변

0
  1. LinearLayout를 제거하고 ToolBar의 컨테이너 android.support.design.widget.AppBarLayout를 추가합니다.

  2. FrameLayoutandroid.support.design.widget.AppBarLayout 외부에 유지하십시오.

  3. 추가 app:layout_behavior="@string/appbar_scrolling_view_behavior" 다음과 같이 업데이트합니다 activity_main.xml

FrameLayout에 :

activity_main.xml이 도움이 될 것입니다

<?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" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:background="@color/colorBG" 
    android:fitsSystemWindows="true" 
    android:id="@+id/mDrawerLayout" 
    android:layout_height="match_parent" 
    android:layout_width="match_parent" 
    tools:context=".MainActivity"> 

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

     <!-- App Bar--> 
     <android.support.design.widget.AppBarLayout 
      android:id="@+id/appbar" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:fitsSystemWindows="true"> 

      <!-- ToolBar--> 
      <android.support.v7.widget.Toolbar 
       android:background="@color/colorPrimary" 
       android:id="@+id/mToolbar" 
       android:layout_height="50dp" 
       android:layout_width="match_parent" 
       android:minHeight="?attr/actionBarSize" 
       android:theme="@style/AppTheme.Toolbar" 
       app:layout_scrollFlags="scroll|enterAlways"/> 
     </android.support.design.widget.AppBarLayout> 

     <!-- Content--> 
     <FrameLayout 
      android:id="@+id/containerView" 
      android:layout_height="match_parent" 
      android:layout_width="match_parent" 
      app:layout_behavior="@string/appbar_scrolling_view_behavior"> 
     </FrameLayout> 
    </android.support.design.widget.CoordinatorLayout> 

    <android.support.design.widget.NavigationView 
     android:background="@color/colorPrimaryLight" 
     android:id="@+id/mNavigationView" 
     android:layout_gravity="start" 
     android:layout_height="match_parent" 
     android:layout_width="wrap_content" 
     app:headerLayout="@layout/header" 
     app:itemBackground="@color/colorPrimaryLight" 
     app:itemIconTint="@color/colorText" 
     app:itemTextColor="@color/colorText" 
     app:menu="@menu/drawer"/> 

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

희망!

+0

감사합니다. @ FerdousAhamed, 이것은 기능입니다. 그러나 내 FrameLayout은 ViewPager로 TabLayout을 가져 오므로 기본적으로 전체 설치가 작동하지 않습니다. –

관련 문제