what's the difference between windowActionBar and android:windowActionBar

10,744

Solution 1

windowActionBar is an attribute provided in AppCompat library, where as android:windowActionBar is provided in Material theme.

The action bar is going away when you set below code, just because you are using AppCompat library and referring the attribute provided in this library itself:

<item name="windowActionBar">false</item>

On another points, it's same as colorPrimary and android:colorPrimary attribute and all other similar attributes.

For example:

We were using Material theme and referring android:colorPrimary attribute as below:

<style name="AppTheme" parent="android:Theme.Material.Light">
        <item name="android:colorPrimary">@color/primary</item>
        <item name="android:colorPrimaryDark">@color/primary_dark</item>
        ....
        ....
</style>

but we are now using AppCompat library with only colorPrimary attribute, for providing compatibility to lower versions.

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>

        ...
        ...

</style>

Solution 2

android:windowActionBar denotes property for lollipop and above only. Where as windowActionBar denotes for all versions and is retrieved from support library.

Share:
10,744
Admin
Author by

Admin

Updated on June 09, 2022

Comments

  • Admin
    Admin almost 2 years

    when I set thestyle in this:

    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
            <item name="colorPrimary">@color/colorPrimary</item>
            <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
            <item name="colorAccent">@color/colorAccent</item>
            <item name="windowActionBar">false</item>
            <item name="windowNoTitle">true</item>
    </style>
    

    the actionbar will go away.

    however,when I set it in this:

    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
            <item name="colorPrimary">@color/colorPrimary</item>
            <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
            <item name="colorAccent">@color/colorAccent</item>
            <item name="android:windowActionBar">false</item>
            <item name=“android:windowNoTitle">true</item>
    </style>
    

    the actionbar is still here.

    what's the difference ?