android – Status bar transparency doesn't work
I am trying to make status bar transparent in my application using this code:
getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
getWindow().setStatusBarColor(Color.TRANSPARENT);
But it doesn’t work. Status bar just change a color and became grey, not transparent. Where is my mistake? How to make status bar transparent?
TOP ANSWERS
Answer # 1
You can maybe check one of my previous answers: stackoverflow.com/a/33986302/3426717
Added by Andrei
Answer # 2
No, it doesn't work.
class=”comment-user owner”>BArtWell
Answer # 3
Tests are being conducted on devices +19? What's the final result using this solution?
Added by Ismael Di Vita
Answer # 4
Yes, Nexus 5 with Android 5.1.1. Status bar became grey, but not transparent.
class=”comment-user owner”>BArtWell
Answer # 5
WithgetWindow().setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
it works. Thank you!
class=”comment-user owner”>BArtWell
Answer # 6
Same result: status bar became grey, but not transparent.
class=”comment-user owner”>BArtWell
OTHER ANSWERS
Answer # 7
Try this in your styles.xml(v21)
<name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:windowTranslucentStatus">true</item>
Update
You can achieve the same effect programatically on KitKat and afterwards by setting this Window flag
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
Window w = getWindow(); // in Activity's onCreate() for instance
w.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
}
If you set a background resource (like a color or a picture) to your layout, you will see the color or picture “below” the status bar.
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">@color/primary_dark</item>
Answer # 8
try calling this from onCreate:
getWindow().getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
getWindow().setStatusBarColor(Color.TRANSPARENT);
47 4 | I want to have appcompat v21 toolbar in my activity. But the toolbar I'm implementing is overlapping below status bar. How can I fix it? Here is the activity layout xml:
Toolbar view:
Theme style:
| |||
79 | Use
| ||||||||||||||||||||
|
5 | Just set this to v21/styles.xml file
and be sure
| ||||||||||||||||
|
4 | For me, the problem was that I copied something from an example and used
Removing this fixed the problem. | ||||
1 | I removed all lines mentioned below from /res/values-v21/styles.xml and now it is working fine.
| ||
1 | None of the answers worked for me, but this is what finally worked after i set
Make sure you don't have the following line as AS put it by default:
|
'모바일개발(Mobile Dev) > 안드로이드개발(Android)' 카테고리의 다른 글
PrefereceActivity SubActivity with Back Button (arrow) (0) | 2016.09.25 |
---|---|
ActionBar and PreferenceActivity headers (0) | 2016.09.18 |
Android UI : Fixing skipped frames (0) | 2016.09.11 |
android upload example (0) | 2016.09.09 |
Button Event Case (0) | 2016.09.09 |
Theme
of your applicaiton? post them. – SilentKnight Apr 20 '15 at 2:46