ajganiev
ajganiev

Reputation: 3

Android development - Status Bar not showing on pre Lollipop (AppCompat)

I'm developing my app using appcompat v21.0.3 and testing on API 21 android ver 5.0.1.Today I decided to test the application on the tablet with Android 4.4.2, and everything would be ok but I did notice that the status bar has become transparent and dropped to toolbar. I have attached pictures and i hope for your help. P.S Sorry for my english, i used google translator to make this text :)

It looks like this https://i.sstatic.net/W4Sve.png But should look like this https://i.sstatic.net/fR1B7.jpg

Upvotes: 0

Views: 5124

Answers (2)

Abhinav singh
Abhinav singh

Reputation: 1456

Add this code in your app style.xml.

   

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->
     <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorPrimary">@color/primarycolor</item>
    <item name="android:textSize">24sp</item>
    <item name="android:actionBarTabStyle">@color/Textcolor</item>


</style>

Upvotes: 0

divyenduz
divyenduz

Reputation: 2027

In your manfest replace

android:theme="@style/AppTheme"

with

android:theme="@style/Theme.AppCompat.Light.NoActionBar"

Use the below code the your Main Activity to assign color to status bar.

if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            Window window = this.getWindow();
            window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
            window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
            window.setStatusBarColor(this.getResources().getColor(R.color.main_red_dark));
        }

Of course, this is just one way. I am not 100% sure, where your are actually changing the code of status bar. It has to be done.

Upvotes: 1

Related Questions