Jumpa
Jumpa

Reputation: 4409

Overlaying Action Bar

I'm trying to overlay action bar. I'm targetting API level 8 up to 19. From official documentation:

<resources>
    <!-- the theme applied to the application or activity -->
    <style name="CustomActionBarTheme"
           parent="@android:style/Theme.AppCompat">
        <item name="android:windowActionBarOverlay">true</item>

        <!-- Support library compatibility -->
        <item name="windowActionBarOverlay">true</item>
    </style>
</resources>

"Also notice that this theme includes two definitions for the windowActionBarOverlay style: one with the android: prefix and one without. The one with the android: prefix is for versions of Android that include the style in the platform and the one without the prefix is for older versions that read the style from the Support Library." Whan i add item for the support library, Eclipse reports an error:

android:windowActionBarOverlay requires API level 11 (current min is 8)

How can I solve this? Many thanks in advance.

Upvotes: 2

Views: 3431

Answers (2)

Bernard
Bernard

Reputation: 21

Had the same problem (and wonder why this isn't mentioned in the official docs). Just suppress the warnings using this additional tools:ignore statement:

<item name="android:windowActionBarOverlay" tools:ignore="NewApi">true</item>

And to make that work you'll need the namespace as well:

<resources xmlns:tools="http://schemas.android.com/tools" xmlns:android="http://schemas.android.com/apk/res/android">

Upvotes: 2

fire in the hole
fire in the hole

Reputation: 1201

I've ran into that problem too, I fixed it by adding tools:tagetApi="11" property:

<item tools:targetApi="11" name="android:windowActionBarOverlay">true</item>

you should also add xmlns to the resource tag of your xml file as well:

<resources xmlns:tools="http://schemas.android.com/tools" xmlns:android="http://schemas.android.com/apk/res/android">

Upvotes: 3

Related Questions