0

I am trying to achieve my action bar which comes with android studio,look like this enter image description here.

I am trying to make the action bar transparent.

I have tried this , this and lots of other things. I am a newbie in xml design and styling in android.

Here is my styles.xml

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
    </style>

    <style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />

    <style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />

Is there a way to achieve this? Thanks in advance.

Subin Chalil
  • 3,531
  • 2
  • 24
  • 38

2 Answers2

2

Instead of doing this with style file, try to to implement this in your java file.Put the following function in your activity in which you want this functionality. In onCreate() method before setting the content view of activity, call this method. It will work for API level 21 and above smoothly.

    public void makeActivityFullscreenTransparent(){


    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);

    // Making notification bar transparent
    if (Build.VERSION.SDK_INT >= 21) {
        getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
    }

    }
jack jay
  • 2,493
  • 1
  • 14
  • 27
  • I am looking for transparent action bar we will look later into notification bar .. thanks for helping – Subin Chalil Jun 12 '17 at 02:51
  • Above performs the same function, also if you want that action bar will disappear after few seconds above is the good code else you can remove first two lines of function. – jack jay Jun 12 '17 at 02:54
1

Try this :

enter image description here

In style.xml :

    <style name="AppTheme.ActionBar.Transparent" parent="AppTheme">
        <item name="android:windowContentOverlay">@null</item>
        <item name="windowActionBarOverlay">true</item>
        <item name="colorPrimary">@android:color/transparent</item>
    </style>

In activity :

 getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);

In layout add this line to main element :

android:fitsSystemWindows="true"

Vidhi Dave
  • 5,614
  • 2
  • 33
  • 55