Reputation: 76
How can I extend the AppBar background to statusbar? Is it possible?
Upvotes: 1
Views: 1772
Reputation: 3500
Before API30, it was possible to achieve the effect using:
Theme.MaterialComponents.Light.NoActionBar
window.setFlags(
WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS,
WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS
)
android:fitsSystemWindows="true"
for top layoutI do not know solution for API30+
Upvotes: 0
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
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