Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android nougat status bar shows white color when launching an activity

In my android application, I have a MainActivity say M. this activity uses Android's tabLayout widget to initialize four tabs. Each tab corresponds to one Fragment say F1,F2,F3,F4 are four fragments.

From F2 , i am launching an activity say C . But while C is being launched the status bar on my device flickers for a moment. By flickering i mean, originally its dark (black) colors . then it fades a bit to white color and again becomes dark. Now C gets launched . When i try to exit from C, back to F2 (by pressing navigation back button) again same effect is shown, But this time it gets worse . I mean the status bar remains in white color for a bit long . Then it goes back to dark color.

I am observing this issue only on android Nougat. On the previous versions its wokring .

So far i have tried How do I prevent the status bar and navigation bar from animating during an activity scene animation transition?

The above link has two approaches : Appraoch 1. It did not work for me Approach 2. My application crashes , because findViewById(android.R.id.statusBarBackground); returns null.

Please suggest how i can solve this problem .

like image 899
Pardeep Kr Avatar asked Nov 30 '16 10:11

Pardeep Kr


1 Answers

Add <item name="android:windowIsTranslucent">true</item> In your activity theme value-v21/syles.xml.
Because android:windowIsTranslucent will make My phone(Api=19) status bar show white for a moment.And cause the activity translate animator not work.
So your can create value-v21 and add the code in styles.xml.

like image 130
LeeYaochi Avatar answered Sep 23 '22 00:09

LeeYaochi