简体   繁体   中英

Scrim on statusbar with ScrimInsetsFrameLayout draws below its childs

I would like to achieve ActionBar with gradient covered with statusbar. I am able to use such a code:

<android.support.design.internal.ScrimInsetsFrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    app:insetForeground="#4000"
    android:background="#e23">
    <View
        android:layout_width="match_parent"
        android:layout_height="140dp" />
</android.support.design.internal.ScrimInsetsFrameLayout>

Having:

http://i.stack.imgur.com/ubBIy.png

But when I add anything inside (as a child) ScrimInsetsFrameLayout, top scrim is covered by (is below) this view:

<android.support.design.internal.ScrimInsetsFrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    app:insetForeground="#4000">
    <android.support.v7.widget.Toolbar
        xmlns:toolbar="http://schemas.android.com/apk/res-auto"
        toolbar:theme="@style/styleActionBarThemeOverlay"
        toolbar:popupTheme="@style/styleActionBarPopupThemeOverlay"
        android:id="@+id/toolbar"
        android:background="@drawable/gradient_actionbar"
        toolbar:titleTextAppearance="@style/styleToolbarTitle"
        toolbar:contentInsetStart="0dp"
        android:layout_width="match_parent"
        android:layout_height="?actionBarSize" />
</android.support.design.internal.ScrimInsetsFrameLayout>

Screen:

http://i.stack.imgur.com/8WFTN.png

Because of next design-plans, I can't set background to ScrimInsetsFrameLayout. How to force scrim above other elements?

I am fed up with it: ScrimInsetsFrameLayout DOESNT WORK IF IT HAS NO BACKGROUND.

<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
    android:fitsSystemWindows="true">
<android.support.design.internal.ScrimInsetsFrameLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#f29"
    android:fitsSystemWindows="true">

    <include layout="@layout/toolbar" />

</android.support.design.internal.ScrimInsetsFrameLayout>
<FrameLayout
    android:id="@+id/navigation"
    android:layout_width="@dimen/navigation_drawer_width"
    android:layout_height="match_parent"
    android:layout_gravity="left|start">

</FrameLayout>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM