2015-11-17 121 views
0

當在frameLayout上使用android:fitsSystemWindows="true"兩次第二個 android:fitsSystemWindows="true"被忽略,我得到的結果顯示在圖像中。我期待第二個框架佈局適合第一個不在導航欄或狀態欄下面。爲什麼? 佈局,我用: 第二個屬性android:fitsSystemWindows =「true」被忽略

<View 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_weight="1" 
    android:background="@color/colorAccent" /> 

<FrameLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_weight="1" 
    android:fitsSystemWindows="true"> 

    <View 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:background="@color/colorPrimary" /> 
</FrameLayout> 

<FrameLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_weight="1" 
    android:fitsSystemWindows="true"> 

    <View 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:background="@color/colorPrimaryDark" /> 
</FrameLayout> 

</LinearLayout> 

和活動風格

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> 
    <item name="colorPrimary">@color/colorPrimary</item> 
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item> 
    <item name="colorAccent">@color/colorAccent</item> 
    <item name="android:windowTranslucentStatus">true</item> 
    <item name="android:windowTranslucentNavigation">true</item> 
</style> 

回答

1

請求到指定窗口插圖適用於你的第二個觀點。您需要在應用後立即執行此操作。

ViewCompat.dispatchApplyWindowInsets(View view, WindowInsetsCompat insets) 

這樣設置跟隨您的第一個視圖的監聽器。

ViewCompat.setOnApplyWindowInsetsListener(View v, OnApplyWindowInsetsListener listener)