I am building an Android app and want to have a button always visible on the actionBar. I followed this guide and others, but none of them seem to solve my problem (although they are very close I guess...).
I have the package "app" and use app:showAsAction="always". No error is shown, but no button on the bar as well. When I change it to android:showAsAction="always" the button appears on the bar, but AndroidStudio tells me I should go for "app:showAsAction with appCompat...".
I have a custom theme with parent="#android:style/Theme.Holo.Light.DarkActionBar"> and for the bar itself: parent="#android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">.
Should I change something and get app:showAsAction working, or ignore AndroidStudio error message and go for android:showAsAction?
This is the documentation of the lint rule:
AppCompatResource
Summary: Menu namespace
Priority: 5 / 10
Severity: Error
Category: Usability
When using the appcompat library, menu resources should refer to the
showAsAction in the app: namespace, not the android: namespace.
Similarly, when not using the appcompat library, you should be using the
android:showAsAction attribute.
I think the problem is that you are mixing Framework Activity and AppCompat menu.
You should use AppCompatActivity with AppCompat Action bar and app:showAsAction; or Activity with android:showAsAction.
Related
I wanted to replace the deprecated version of android.support.v4.app.ActionBarDrawerToggle so i looked a little and found how to do it : How to implement DrawerArrowToggle from Android appcompat v7 21 library
Except it doesnt work : I get this error This Activity already has an action bar supplied by the window decor
And if I change the style the action bar wont be seen.
I am building an Android app and want to have a button always visible on the actionBar. I followed this guide and others, but none of them seem to solve my problem (although they are very close I guess...).
I have the package "app" and use app:showAsAction="always". No error is shown, but no button on the bar as well. When I change it to android:showAsAction="always" the button appears on the bar, but AndroidStudio tells me I should go for "app:showAsAction with appCompat...".
I have a custom theme with parent="#android:style/Theme.Holo.Light.DarkActionBar"> and for the bar itself: parent="#android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">.
Should I change something and get app:showAsAction working, or ignore AndroidStudio error message and go for android:showAsAction?
This is the documentation of the lint rule:
AppCompatResource
Summary: Menu namespace
Priority: 5 / 10
Severity: Error
Category: Usability
When using the appcompat library, menu resources should refer to the
showAsAction in the app: namespace, not the android: namespace.
Similarly, when not using the appcompat library, you should be using the
android:showAsAction attribute.
I think the problem is that you are mixing Framework Activity and AppCompat menu.
You should use AppCompatActivity with AppCompat Action bar and app:showAsAction; or Activity with android:showAsAction.
I have put two icons from Android Icon Packager for action bar. The Info Action appears brightly while the next one, Refresh Action is not appearing. I use both as holo_dark. I tried switching just the refresh action, and it appears very very dimly.
I've try reading many many stuffs I seem to find nothing about this topic.
EDIT: I have solved this problem by deleting the whole refresh icon and then remove the line
android:icon="#drawable/ic_action_refresh"
in the XML. I then re-added the icon and it works like a charm. Voted both answer for caring about my question
Use Icon from your Android Package Opposite to Your Theme.
For eg: If you are using Holo_Dark Theme in your Application use Holo_White Icon Set for it.
I am trying to update my app with the new ActionBar paradigm. I want to keep compatibility backwards though, as my largest user base is still on Gingerbread.
To that end, I am trying to integrate ActionBarSherlock into my app.
My app is designed to use the dialog theme, so when I integrated ABS, I tried to use the corresponding dialog theme as so in my AndroidManifest.xml:
<application android:theme="#style/Theme.Sherlock.Dialog" >
My ActionItems would not show up though, and only appeared as old-school menu items (meaning they were completely inaccessible on my tablet). Looking at the samples in the ABS download, I decided to try changing my app and removing the .Dialog qualifier, changing my AndroidManifest.xml to:
<application android:theme="#style/Theme.Sherlock" >
Once I did that, the menu items moved from the menu to the ActionBar, where I expected and want them to be. So it would seem that, with default conditions, ActionItems are not enabled when using the .Dialog theme.
Is there any way to enable this behavior, so that the menu items would show in the ActionBar as expected while still using the dialog theme?
I am completely baffled. I created an application with minSDK=4 and targetSDK=11. Compiled and ran on the Xoom tablet. I am not getting an Action Bar and cannot figure out what I have done wrong. I have been staring at the screen for hours and don't know what I have done that would have caused the bar to disappear. Help! Any suggestions on why I am not seeing the Action Bar?
You need to declare android:theme="#android:style/Theme.Holo" for Activity in Manifest xml.
The dev guide says like you only need to set the target SDK version, but it does not work.
I'm quoting from here:
"If you are using the Support Library APIs for the action bar, then you must use (or override) the Theme.AppCompat family of styles (rather than the Theme.Holo family, available in API level 11 and higher)."
I used android:theme="#style/Theme.AppCompat" in my manifest and the action bar appeared.
Romulus' answer, forcing the App to use the Holo theme will work but it results in a compile error if your minSDK is less than 11.
Check if you have defined a theme in the AndroidManifest:
android:theme="#style/XXXXXXXXXXXXXXXXX"
That means you're forcing the App to use a particular theme, so the action bar might not appear on Honeycomb or higher devices (it depends if the theme specifies an action bar). Delete this statement to cause the App to use the default device theme, so the Settings menu appears on pre-Honeycomb devices and the action bar appears on post-Honeycomb devices. Job done. Hope this helps.