0

I follow some tutorial on the internet to make status bar on api19 (kitkat) transparent, but i got something like this (android:theme="@style/AppTheme.NoActionBar" style) enter image description here

and v-19\styles.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="AppTheme" parent="AppTheme.Base">
        <item name="android:windowTranslucentStatus">true</item>
    </style>
</resources>

styles.xml

<style name="AppTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
        <item name="colorPrimary">@color/primary</item>
        <item name="colorPrimaryDark">@color/primary_dark</item>
        <item name="colorAccent">@color/accent</item>
        <item name="colorControlHighlight">@color/accent</item>
        <item name="android:textColorSecondary">@color/primary</item>
        <item name="android:popupMenuStyle">@style/AppTheme.PopupOverlay</item>
        <item name="android:popupBackground">@color/light</item>
    </style>

how i turn the white translucent become transparent or colored primary so it will be blended with actionbar..

Ameer
  • 2,709
  • 1
  • 28
  • 44
Angga Ari Wijaya
  • 1,759
  • 1
  • 15
  • 31
  • You can simply call in your activity: `getActionBar().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));` – Opiatefuchs Apr 21 '16 at 08:53
  • ps : since Android 3.0 ....and maybe you should be a little bit more secure by `ActionBar ab = getActionBar(); if(ab!=null){}`...etc.... – Opiatefuchs Apr 21 '16 at 08:59
  • thanks for the feedback, but it's not work for me... still gradient black to white on status bar.. – Angga Ari Wijaya Apr 21 '16 at 09:24
  • ahh, you wanted the system bar to change? Sorry, from your code I thought you want to change actionBar..for systembar see here:http://stackoverflow.com/questions/22192291/how-to-change-the-status-bar-color-in-android – Opiatefuchs Apr 21 '16 at 09:36
  • that link reference for lollipop, i want implement translucent status bar on kitkat, not completely change the color but fade from dark to transparent kitkat status bar on my app.. – Angga Ari Wijaya Apr 21 '16 at 10:07
  • as the first answer suggested, possible for pre lollipop with `library support-v7-appcompat ` – Opiatefuchs Apr 21 '16 at 10:13

2 Answers2

1

Add this to your v-19\styles.xml

<style name="AppTheme" parent="AppTheme.Base">
        <item name="android:windowTranslucentStatus">true</item>
        <item name="android:windowTranslucentNavigation">true</item>
</style>

and the following property to root layout of your xml file:

android:fitsSystemWindows="true"
Hello World
  • 2,764
  • 1
  • 11
  • 23
1

I found a solution for myself, we need to create styles value for v19\styles.xml like below

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="AppTheme" parent="AppTheme.Base">
        <item name="android:windowTranslucentStatus">true</item>
        <item name="android:windowTranslucentNavigation">true</item>
        <item name="android:windowBackground">@color/primary</item>
        <item name="android:clipToPadding">false</item>
    </style>
</resources>

if we use CoordinatorLayout as root view we got translucent status bar and navigation bottom bar fade with android:windowBackground color, if we use general layout like Linear or Relative layout we got completely transparent status and navigation bar like we use DrawerLayout it will give same result. adding android:fitsSystemWindows="true" in root layout will give content keep inside the application container to avoid collapse or overlapping with status bar or navigation bar.

Angga Ari Wijaya
  • 1,759
  • 1
  • 15
  • 31