I need to make transparent status bar. I am using getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS)
and it is make status bar as I want. Bu
getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
i found the solution bro
<style name="transparent" parent="Theme.AppCompat.Light.NoActionBar">//AppCompat is the key; You can choose any other theme than the light-theme, but stick to AppCompat
<item name="android:windowTranslucentStatus">false</item>
<item name="android:windowDrawsSystemBarBackgrounds">false</item>
//Other styling(optional)
</style>
and then apply this transparent theme to your activity manifest like this
<activity
...
android:theme="@style/transparent"/>
this work for me
getWindow().setFlags(
WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,
WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS
)
styles.xml
<style name="TranslucentStatusBar" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowTranslucentStatus">true</item>
</style>
v21\styles.xml
<style name="TranslucentStatusBar" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowDrawsSystemBarBackgrounds">false</item>
<item name="android:windowTranslucentStatus">true</item>
</style>
status bar will be transparent or translucent, navigation bar won't
hope this helps!
This works on Samsung S10+ (Pie), Oppo F7 and Oppo F5S (Oreos):
getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_IN_OVERSCAN);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
As asked by the original poster, the app area is expanded on top and covers the status bar (where the clock is). But the android navigation (virtual) buttons remains at the bottom of the screen and the app sits on top of the android buttons.
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
Just flag above worked for me. Navigation buttons are visible, status bar and action bar are hidden.
getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
Is not working. Test device nexus 5.
For all those interested in workarounds/hacks because Android API concerning this matter is just awful. Do not use any system window flags, set negative margin to the root of your layout, and then use setStatusBarColor
to make your StatusBar
transparent.
statusBarHeight = getResources().getDimensionPixelSize(R.dimen.margin_24dp);
int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android");
if (resourceId != 0) {
statusBarHeight = getResources().getDimensionPixelSize(resourceId);
}
FrameLayout.LayoutParams rootParams = (FrameLayout.LayoutParams) binding.getRoot().getLayoutParams();
rootParams.topMargin = -statusBarHeight;
binding.getRoot().setLayoutParams(rootParams);
getWindow().setStatusBarColor(getResources().getColor(R.color.transparent));
where binding.getRoot() is of course the root of your layout
and result is