Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android:windowActionBarOverlay & android:actionBarStyle requires api level 11

Tags:

android

I am making an android app and using android-support-v7-appcompat to make sure my app support action bars from android version 2.2 and up.

I need to make the Action Bar overlay and use a translucent background so I have modified the styles.xml to this code :

    <resources>

    <style name="AppBaseTheme" parent="android:Theme.Light">
        <!--
            Theme customizations available in newer API levels can go in
            res/values-vXX/styles.xml, while customizations related to
            backward-compatibility can go here.
        -->
    </style>

    <!-- Application theme. -->
    <style name="AppTheme" parent="AppBaseTheme">
        <!-- All customizations that are NOT specific to a particular API-level can go here. -->
    </style>

    <!-- TRANSLUCENT THEME -->
    <style name="TranslucentAB" parent="Theme.AppCompat.Light">
        <item name="windowActionBarOverlay">true</item>
        <item name="android:windowActionBarOverlay">true</item>
        <item name="android:actionBarStyle">@style/BlackBar</item>
        <item name="actionBarStyle">@style/BlackBar</item>
    </style>

    <!-- TRANSLLUCENT COLOR STYLE -->
    <style name="BlackBar" parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
        <item name="android:background">@drawable/halfblack</item>
        <item name="background">@drawable/halfblack</item>
    </style>

</resources>

and modified manifest file to adapt the new ActionBar as :

android:theme="@style/TranslucentAB"

The problem is that the following two lines of code require API level 11 and up :

<item name="android:windowActionBarOverlay">true</item>
<item name="android:actionBarStyle">@style/BlackBar</item>

but I need to support from API level 8 and up. If I remove these two lines the app runs fine on Android 2.2 with black translucent action bar. But if I run the app in Android 4.3 the app launches with a solid white action bar. halfblack is just a png file in drawable folder with 70% black color.

like image 818
Rakesh Avatar asked Dec 15 '22 01:12

Rakesh


1 Answers

Found solution to my problem :

I have to make separate styles.xml in res/values-v11 to support the same functionality in android 3.0 and up

like image 118
Rakesh Avatar answered May 20 '23 18:05

Rakesh