Sigitas
Sigitas

Reputation: 163

second attribute android:fitsSystemWindows="true" is ignored

when using android:fitsSystemWindows="true" two times on frameLayout the second android:fitsSystemWindows="true" is ignored and i get the result displayed in the image. i was expecting the second frame layout to be fitted same as the first one not going under the navigationbar or statusbar. why is that so? layout that i used:

<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>

and activity style

<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>

Upvotes: 0

Views: 750

Answers (1)

boyeong
boyeong

Reputation: 11

Request to apply the given window insets to your second view. you need to do that right after it's applied.

ViewCompat.dispatchApplyWindowInsets(View view, WindowInsetsCompat insets)

so set follow listener to your first view.

ViewCompat.setOnApplyWindowInsetsListener(View v, OnApplyWindowInsetsListener listener)

Upvotes: 1

Related Questions