2015-11-17 123 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)