I want to customize text style Android menu item.
I put this to styles.xml
<item name="android:actionMenuTextAppearance">#style/my_custome_actionbar_menu_item</item>
It does not work, but when I remove "android:", it work properly
<item name="actionMenuTextAppearance">#style/my_custome_actionbar_menu_item </item>
Do you know What is different between having "android: " and not?
if you use api7-13,use actionMenuTextAppearance,and if your sdk api>17,use android:actionMenuTextAppearance,maybe the sdk you are using is lower than 17.
I figure out the reason about AppCompat
With new AppCompat-v7 (v21) ActionBar style's properties need to refer to the app namespace, that is without android: prefix.
So,for retro-compatibility, we should use actionBarStyle along with android:actionBarStyle:
Related
I'm using Toolbar as setSupportActionBar(toolbar). How i can change action mode background color. I try in my App Theme change attribute:
<item name="android:actionModeBackground">#color/color</item>
But it is not working. How can I solve this problem?
The AppCompat library supports versions of Android that don't have ActionBars, so it needs to define attributes to use that wouldn't exist on those devices. You want to use this:
<item name="actionModeBackground">#color/color</item>
The same goes for any other style/theme attributes you want to use that have been backported. But you'd use platform ones that exist, like android:textColor or android:background.
I have used Android Support V7's #style/Theme.AppCompat.Light for my styles. And to be more specific I have used Actionbar Style Generator
I want my overall theme to be in light red. So,for options menu item selector,I need light red color to work. I have made Accent color in Actionbar Style Generator to red as well. But the options menu item is always default blue. I have changed following as well to be sure
<item name="popupMenuStyle">#style/PopupMenu.Fsa</item>
<item name="dropDownListViewStyle">#style/DropDownListView.Fsa</item>
<style name="DropDownListView.Fsa" parent="#style/Widget.AppCompat.Light.ListView.DropDown">
<item name="android:listSelector">#drawable/red_selector</item>
</style>
But also,the options menu item selector is always default blue. I have browsed several tutorials on Actionbar styling and they were also of no help. So any help would be greatly appreciated.
Depending on your hardware needs Android Support or not, your XML must contain both item style reference:
<!-- Support library compatibility -->
<item name="popupMenuStyle">#style/PopupMenu.Fsa</item>
<item name="dropDownListViewStyle">#style/DropDownListView.Fsa</item>
and
<!-- Support library not needed -->
<item name="android:popupMenuStyle">#style/PopupMenu.Fsa</item>
<item name="android:dropDownListViewStyle">#style/DropDownListView.Fsa</item>
regardless the fact of Android Studio show error for "requires API level XX", it compiles as well and now the correct styles are applicable in both hardware, who needs and not the support library.
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').
In my app I'm using the ActionBarCompat Theme.AppCompat (like holo but backwards compatable) style but I'd like to use the Theme.AppCompat.Light.DarkActionBar style for the action bar only.
So far I've tried numerous things in xml,
<item name="actionBarStyle">#style/Widget.AppCompat.Light.ActionBar.Solid.Inverse</item>
but it doesn't change the ActionBar at all.
Any Suggestions?
Thank you
Try to use
<item name="actionBarStyle">#style/Widget.AppCompat.Light.ActionBar.Solid.Inverse</item>
<item name="android:actionBarStyle">#style/Widget.AppCompat.Light.ActionBar.Solid.Inverse</item>
first line for preICS platforms, second for ICS. or you can split this style between values and values-v14 folders
for the last few days I'm trying to implement custom theme, which is created by Action Bar Style Generator to my application. I'm able to use theme with some generic samples from SDK, but I'm not able to use it with my application which uses ActionBarSherlock.
My application with ActionBarSherlock is a modified sample of Tabs and Pager.
Steps which I do:
Create theme with Android Action Bar Style Generator.
Copy theme to res folder inside my application.
Change theme in Manifest file.
After those steps only 'Action bar color' changes to correct one. All other styles are not used in application. I have tried many different approaches which I found online, but without success.
Thank you very much for your help.
Did you add the proper items to your App's theme in styles.xml? You need to use attributes that are NOT prefixed with android:, for example:
<item name="actionBarStyle">#style/Widget.Styled.ActionBar</item>
<item name="background">#drawable/bg_striped</item>
<item name="backgroundSplit">#drawable/bg_striped_split</item>
You would also keep the properly prefixed ones for Android versions that have native actionbar.
<item name="android:actionBarStyle">#style/Widget.Styled.ActionBar</item>
<item name="android:background">#drawable/bg_striped</item>
<item name="android:backgroundSplit">#drawable/bg_striped_split</item>
The best place to understand this is to look at the demo provided with the ActionBarSherlock library project.
I managed to fix the problem.
I missed android:background attribute in TabWidget. This partially
solves the problem.
I had to set setLeftStripDrawable and setRightStripDrawable programatically.