简体   繁体   中英

Change status bar scrim color with collapsing toolbar layout

I`m using android palette API to extract colors from the downloaded images by picasso, and accordingly i wanna change status bar and collapsing toolbar color. i managed to change the collapsing toolbar but i cant with the status bar! and this is my code


collapsingToolbar.setBackgroundColor(palette.getLightVibrantColor(00000)); // 00000 just for testing!

collapsingToolbar.setContentScrimColor(palette.getLightVibrantColor(00000));

collapsingToolbar.setStatusBarScrimColor(palette.getLightVibrantColor(00000));

<android.support.design.widget.AppBarLayout
        android:id="@+id/appbar"
        android:layout_width="match_parent"
        android:layout_height="300dp"
        android:fitsSystemWindows="true">

        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/collapsing_toolbar"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:contentScrim="@color/colorPrimary"
            app:layout_scrollFlags="scroll|exitUntilCollapsed"
            app:statusBarScrim="@android:color/transparent">

            <ImageView
                android:id="@+id/back_drop"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:scaleType="centerCrop" />

            <android.support.v7.widget.Toolbar
                android:id="@+id/detail_toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                app:layout_collapseMode="pin" />

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

use this method

  private void applyPalette(Palette palette) {
    int primaryDark = getResources().getColor(R.color.primary_dark);
    int primary = getResources().getColor(R.color.primary);
    collapsingToolbarLayout.setContentScrimColor(palette.getMutedColor(primary));
    collapsingToolbarLayout.setStatusBarScrimColor(palette.getDarkMutedColor(primaryDark));
    supportStartPostponedEnterTransition();
}

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