Android custom actionbar overlay - android

So i have been following the tutorials on the android developer website. i have created an android project with min SDK of 8, and included the compatibility for the android 2.1 for the menu bar. i am able to get the menu bar to work properly for android 4.0 and 2.2, no issues.
now i am trying to set the overlay for the menubar, and i ran into an issue. while setting up a custom theme with the parent being an AppCompact theme, as stated here http://developer.android.com/training/basics/actionbar/overlaying.html .
the code with the issue is :
<!-- 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>
2 issues arise:
error: Error retrieving parent for item: No resource found that
matches the given name '#android:style/ Theme.AppCompat'.
and
android:windowActionBarOverlay requires API level 11 (current min is
8)
the first issue, i have no idea why it is being thrown. i use Theme.AppCompact in my manifest and it works. the 2nd issue is confusing me, in the google tutorials it states to include both definitions, as one is for android devices with the new API and the other is for older API's.
i have tried to clean/build my project, it did not help.

Solved by replacing
parent="#android:style/Theme.AppCompat"
with
parent="#style/Theme.AppCompat"

Related

ActionBar Menu Theme Issue in Latest Android L release

In the latest Android L emulator released today (17th october 2014) I'm getting strange issue:
the action bar menu font theme seems ignored and the color of the font is black despite I have
`<style name="Theme.MyTheme" parent="#android:style/Theme.Holo.Light.DarkActionBar">`
In the previous release, Android L Preview API level 20, the font color of the action bar menu was correctly rendered with a white color, and also in all previous versions
I have also tried to remove all theme customizations leaving only this
<resources>
<style name="Theme.MyTheme" parent="#android:style/Theme.Holo.Light.DarkActionBar">
<item name="android:actionMenuTextColor">#color/White</item>
</style>
</resources>
With no result.
Is this a bug of the Android Lollipop emulator or should I change something?
Seems pretty strange that everything works fine with Android L preview and with the official release get this issue.
Any suggestion?
Additional Information:
-The emulator configuration is Android Atom x86_64 API Level 21 (tested also on 32 bit version with the same result), use host GPU enabled... tested also with ARM v7 CPU no use host GPU option and get the same result
-The app target set in App Manifest is Android API Level 17, the minimum SDK is API level 14
-The project use the Android Support library v4 released today (17-10-2014)
1) Create a style.xml in a resource folder named values-v21
2) Now you have 2 options
a) Copy your actual style configuration in the new style.xml created, replacing the keyword
Holo with the keyword Material;
b) define new material style from scratch;
this is needed to use the new Material theme on Android L
In this way you will fix all compatibility problems caused by Holo theme on the new Android L

Error retrieving parent for item: No resource found that matches the given name 'Theme.Sherlock.Light'

I am facing this annoying problem with the Action Bar Sherlock (ABS) in a 'theme.xml' file of my Android Library Project that I am creating and I cannot really find a solution to it.
I have referenced the ABS library correctly into my Library Project and the build target of my Library project is currently set to 19 with the minSdkVersion being 8. I have used the ABS before but this is kinda strange.
Here is my theme file:
<style name="Theme.MyTheme" parent="#style/Theme.Sherlock.Light">
<!-- Set style for Action Bar (affects tab bar too) -->
<item name="actionBarStyle">#style/Widget.MyTheme.ActionBar</item>
</style>
I also tried it without the '#style' tag:
parent="Theme.Sherlock.Light"
I have checked out various posts and tried the answers mentioned but it does not seem to work.
Is this because I am creating a Library project? Or Is there a silly issue that I am overlooking?
Any help will be appreciated.

No resource found that matches the given name: attr 'actionBarStyle'

I am trying to change the android action bar style. The minimum API support for the app is 8. So as using android:actionBarStyle attribute in the style xml file in the values folder gives the minimum required API 11 error, I have commented it out and moved it to a separate style xml file in v11 folder.
However, when using the actionBarStyle attribute only for android 2.1 and higher as mentioned in the android documentation, it gives me the No resource found error. Below is the style code:
<style name="AppTheme" parent="android:Theme.DeviceDefault">
<item name="android:typeface">monospace</item>
<!-- <item name="android:actionBarStyle">#style/MyActionBarTheme</item> -->
<!-- Support library compatibility -->
<item name="actionBarStyle">#style/MyActionBar</item>
</style>
I have tried changing the style parent theme from DeviceDefualt to Holo.Light.DarkActionBar, AppCompat.Light.DarkActionBar, etc. but the error still remains.
If you want to use the standard Action Bar on Android devices v7 appcompat library, which backports the Action Bar to any API 7+ device when you use ActionBarActivity. (Note, the Android documentation you found reference this same library, hence the 'When using the Support Library' comments throughout that document)
To add it to your project, you can follow the directions for adding a library with resources for whatever IDE you use.
Once you have the appcompat library added, you may consider using a tool like the Android Action Bar Style Generator which automatically builds the correct styles/resources needed to fully style your action bar (make sure to change the 'Style Compatibility' drop down to 'AppCompat').

How to remove Menu Option in Android 4.2.2

My Android App has min sdk and target sdk set to 10, when I run my app on Nexus 4 -Android Version 4.2.2, it shows a menu option button beside the system navigation.
I am not using menu options in my app and I dont want to show the user this useless menu option. How can I remove it ?
I have read about this on http://android-developers.blogspot.com.au/2012/01/say-goodbye-to-menu-button.html but I do not get a concrete solution.
Attached is the image :
I dont want to change the sdk version for my app. Is it possible to remove menu option without changing sdk version?
You simply have to modify your targetSdk to something above 10. For instance, if you use last SDK you should use targetSdk=16
The concrete solution is in the article:
Add theme to your application:
<application android:theme="#style/NoActionBar">
Then define this theme for pre-Honeycomb in res/values/themes.xml:
<resources>
<style name="NoActionBar" parent="#android:style/Theme">
<!-- Inherits the default theme for pre-HC (no action bar) -->
</style>
</resources>
and for Honeycomb and later:
<resources>
<style name="NoActionBar" parent="#android:style/Theme.Holo.NoActionBar">
<!-- Inherits the Holo theme with no action bar; no other styles needed. -->
</style>
</resources>
If you set your target SDK version to 11 and below, the android legacy menu button will appear. But just in case you want to keep that target SDK version, you can just delete the method onCreateOptionsMenu, this way you won't inflate any options.

Error while deploying sample code by android, project:android api demos

I am getting following error on deploying one of the sample projects given by android: android api demos for api level 8 :
error: Error retrieving parent for item: No resource found that matches the given name 'android:style/Theme.Wallpaper'.
at values/styles.xml line 43
<style name="Theme.Wallpaper" parent="android:style/Theme.Wallpaper">
<item name="android:colorForeground">#fff</item>
</style>
I have been looking for solutions for over a month now. I have tried rebuilding project, dowloading entire source code again and rebuilding and cleaning.
Help
As Very Well Explain by raychenon.
<style name="Theme.Wallpaper" parent="android:style/Theme.Wallpaper" >
<item name="android:colorForeground">#fff</item>
</style>
What is happening is that some styles, like Theme.Wallpaper are not public. You should not extend from them anymore.
Some suggest to revert to platform_tools_r05 HERE
If you want to do the correct way read Xavier July 28 HERE
If you wish to reuse a style that is private, you should copy the
content of that style into your own instead of extending it.
ANSWER
Default theme for windows that want to have the user's selected
wallpaper appear behind them.
<style name="Theme.Wallpaper">
<item name="android:windowBackground">#android:color/transparent</item>
<item name="android:colorBackgroundCacheHint">#null</item>
<item name="android:windowShowWallpaper">true</item>
</style>
Looks like you want to use the above code from the Android source and create your own theme based it.
Hope it Will Helps you.
You can refer to this question posted here and read Xavier's comments on the Google blog..
style reference after SDK and ADT plugin update in mid 2011
Hope it helps..Keep me posted
When you import the Android Samples via "Android projects from existing code", I noticed that the libraries and API number are Android 1.5 and API level 3.
This API Level doesn't support android:style/Theme.Wallpaper.
I fixed it by adjusting the Project Build Target to Android 2.2 (API Level 8) in the Project Properties Menu.

Categories

Resources