Make transparent ActionBar in Android

 

Step1: In value/style.xml:

<style name="AppTheme" parent="Theme.AppCompat.Light">
... 
</style>
<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>

<style name="AppTheme.ActionBar" parent="AppTheme">
    <item name="windowActionBarOverlay">false</item>
    <item name="colorPrimary">@color/default_yellow</item>
</style>

Step2: in AndroidManifest.xml > placed in activity you want to make transparent ActionBar:

<activity
            android:name=".MyTransparentActionbarActivity"
            android:theme="@style/AppTheme.ActionBar.Transparent"/>

NOTE:

f you want to make sure there aren’t Views under your Action Bar, you can add a top margin to it in the XML.

<YourView
    ...
    android:layout_paddingTop="?android:attr/actionBarSize" />

		
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s