Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Transparent actionBar and statusBar in Android lollipop

I am trying to create this interface :

enter image description here

And here is my actual result :

enter image description here

  • The status bar is well transparent and we see my image as background : OK
  • The action bar is not transparent : NOK

Here is the code of my theme that I use for this activity :

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <!-- inherit from the material theme -->
    <style name="MaterialAppDetailTheme" parent="android:Theme.Material.Light">

        <item name="android:statusBarColor">@android:color/transparent</item>
        <item name="android:windowActionBarOverlay">true</item>

        <!-- enable window content transitions -->
        <item name="android:windowContentTransitions">true</item>

        <!-- specify shared element transitions -->
        <item name="android:windowSharedElementEnterTransition">
            @transition/change_image_transform</item>
        <item name="android:windowSharedElementExitTransition">
            @transition/change_image_transform</item>

        <item name="android:windowTranslucentNavigation">true</item>
        <item name="android:windowTranslucentStatus">true</item>

    </style>
</resources>
like image 363
wawanopoulos Avatar asked Feb 04 '15 16:02

wawanopoulos


People also ask

What is ActionBar in Android?

Android ActionBar is a menu bar that runs across the top of the activity screen in android. Android ActionBar can contain menu items which become visible when the user clicks the “menu” button. In general an ActionBar consists of the following four components: App Icon: App branding logo or icon will be displayed here.

How can use no action bar in Android?

If you want to hide Action Bar from the entire application (from all Activities and fragments), then you can use this method. Just go to res -> values -> styles. xml and change the base application to “Theme. AppCompat.


2 Answers

You can change your toolbar color to transparent like this:

mToolbar.setBackgroundColor(getResources().getColor(android.R.color.transparent));

You can change it's background on the XML too:

android:background="@android:color/transparent"

Or if you're using ActionBar:

getSupportActionBar().setBackgroundDrawable(new ColorDrawable(getResources().getColor(android.R.color.transparent)));

Use getActionBar() if you're not using ActionBarActivity

Result:

enter image description here

like image 130
Pedro Oliveira Avatar answered Oct 27 '22 17:10

Pedro Oliveira


Use this style:

<style name="AppTheme" parent="Theme.AppCompat.Light">
    <item name="android:textColorPrimary">@color/my_text_color</item>
    <item name="colorPrimary">@android:color/transparent</item>
    <item name="windowActionBarOverlay">true</item>
</style>
like image 29
GIGAMOLE Avatar answered Oct 27 '22 17:10

GIGAMOLE