Reputation: 18511
There is a post of the same question and it has received an answer. I suspect my case is different and it may indicate a general problem of the project configuration. windowTranslucentNavigation is for API 19. I have set targetSdkVersion inn both build.gradle and manifests. In build.gradle:
defaultConfig {
applicationId "xxx"
minSdkVersion 9
targetSdkVersion 21
// Enabling multidex support.
multiDexEnabled true
}
In manifests:
<uses-sdk
android:minSdkVersion="9"
android:targetSdkVersion="21" />
Android Studio clearly knows about windowTranslucentNavigation. The following warning shows this:
When the project is built, the following error is generated:
Error:(7, 29) No resource found that matches the given name: attr 'windowTranslucentNavigation'.
Here is the contents of themes.xml:
<resources>
<!-- the theme applied to the application or activity -->
<style name="OverlayingActionBarTheme"
parent="@style/Theme.AppCompat">
<item name="android:windowActionBarOverlay">true</item>
<item name="android:actionBarStyle">@style/TransparentActionBar</item>
<item name="android:windowTranslucentNavigation">true</item>
<!-- Support library compatibility -->
<item name="windowActionBarOverlay">true</item>
<item name="actionBarStyle">@style/TransparentActionBar</item>
<item name="windowTranslucentNavigation">true</item>
</style>
<!-- ActionBar styles -->
<style name="TransparentActionBar"
parent="@style/Widget.AppCompat.ActionBar">
<item name="android:background">@color/black_overlay</item>
<!-- Support library compatibility -->
<item name="background">@color/black_overlay</item>
</style>
Could anyone offer a tip on how to fix this?
Upvotes: 0
Views: 1060
Reputation: 11408
The answer that suggests you change your minSdkVersion
to support this is not entirely correct. The feature may not be supported on versions older than 19, but you can use it without changing your minSdkVersion
.
You would create a themes.xml
file in a folder named values-v19
. This will allow you to use SDK 19+ style/theme features on any device that is running that version or above.
More info about how this works: Supporting Different Platform Versions.
Upvotes: 2
Reputation: 20410
You'll need to change your minSdkVersion to 19 if you want to support that, or not use it. In any other circumstance, for example calling a method only supported in a new version, you can programmatically decide not to call it if your version is lower, but in this case you can't change the style programmatically depending on the version.
Upvotes: 1