gabrielepmattia
gabrielepmattia

Reputation: 76

How extend actionbar background to statusbar

Screenshot How can I extend the AppBar background to statusbar? Is it possible?

Upvotes: 1

Views: 1772

Answers (3)

ror
ror

Reputation: 3500

Before API30, it was possible to achieve the effect using:

  1. Theme Theme.MaterialComponents.Light.NoActionBar
  2. Setting window flags:
        window.setFlags(
            WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS,
            WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS
        )
  1. Using android:fitsSystemWindows="true" for top layout

I do not know solution for API30+

Upvotes: 0

Juan Diego Lozano
Juan Diego Lozano

Reputation: 1009

Edit: I originally posted a solution based on a external link, that is not working now. This was the code:

    <item name="android:windowTranslucentStatus">true</item>
    <item name="android:windowTranslucentNavigation">true</item>

And set android:fitsSystemWindows to true

Upvotes: 0

yUdoDis
yUdoDis

Reputation: 1098

call this in your onCreate();

getWindow().getDecorView()
        .setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
getWindow().setStatusBarColor(Color.TRANSPARENT);

sets your view layout as full screen and makes status bar colo transparent, works for Api21 and above.

Upvotes: 4

Related Questions