2017-10-23 4 views
0

コードは以下のとおりです。今度はfitsSystemWindowsはアプリケーションバーでうまく動作しますが、メインコンテンツを表示する下のコードのフレームレイアウトは、fitsSystemWindowsを使用してもフレームバーにtrueを設定しても、アプリケーションバーの下の最初の要素を取得します。なぜそれが動作していないのか理解してください。アンドリッドでfitsSystemWindowsをtrueに設定してもパディングの問題を回避できません

<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:id="@+id/drawer_layout" 
    android:layout_height="match_parent" 
    android:layout_width="match_parent" 
    android:fitsSystemWindows="true" 
    tools:context=".MainActivity"> 


<!-- CoordinatorLayout is used to create scrolling and "floating" effects within a layout --> 
<!-- This is typically the root layout which wraps the app bar and content --> 
<android.support.design.widget.CoordinatorLayout 


    android:id="@+id/content" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <!-- AppBarLayout is a wrapper for a Toolbar in order to apply scrolling effects. --> 
    <!-- Note that AppBarLayout expects to be the first child nested within a CoordinatorLayout --> 
    <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.ActionBar"> 

     <android.support.v7.widget.Toolbar 
      android:id="@+id/toolbar_main" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:background="?attr/colorPrimary" 
      android:theme="@style/ToolbarTheme" 
      app:layout_scrollFlags="scroll|enterAlways" 
      android:minHeight="?attr/actionBarSize" 
      app:titleTextColor="@android:color/white" 
      app:popupTheme="@style/StyleForMyOverflowMenu"> 

      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_gravity="center" 
       android:text="News" 
       android:textColor="@color/white" 
       android:textAppearance="?android:attr/textAppearanceMedium"/> 

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

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

    <!-- The main content view where fragments are loaded --> 
    <FrameLayout 
     android:fitsSystemWindows="true" 
     android:id="@+id/flContent" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" /> 

</android.support.design.widget.CoordinatorLayout> 
    <android.support.design.widget.NavigationView 
     android:id="@+id/navigation_view" 
     android:layout_height="match_parent" 
     android:layout_width="wrap_content" 
     android:layout_gravity="start" 
     app:headerLayout="@layout/drawer_header" 
     app:menu="@menu/drawer"/> 
</android.support.v4.widget.DrawerLayout> 

答えて

0

だけでframeLayoutに "appbar_scrolling_view_behavior" を追加し、問題がお返事のため

<!-- The main content view where fragments are loaded --> 
     <FrameLayout 
      android:fitsSystemWindows="true" 
      android:id="@+id/flContent" 
      app:layout_behavior="@string/appbar_scrolling_view_behavior" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" /> 
+0

感謝を解決しました。できます。しかし、なぜそれが以前にはうまくいかなかったのか、なぜ今働いているのか理解したいと思います。あなたは私がそれを理解するのを助けてもらえますか? –

関連する問題