ActionBarSherlock hardkey menu panel text color - android

I have a small question about theming my app that uses ActionBarSherlock. Everything works fine except on Samsung phones with TouchWizz. The overflow menu items appear by pressing the hardware menu key.
I know how to change the panel background. My default theme extends Theme.Sherlock.Light.DarkActionBar, so the default menu item text color in the hardware panel will be black, I wan't to change this.
Any ideas on how to do this besides changing the parent of my default theme?
<style name="Theme.MyApp" parent="#style/Theme.Sherlock.Light.DarkActionBar">
<item name="android:panelBackground">#drawable/menu_hardkey_panel</item>
</style>

I'm not sure if I understand what you want to do, but if you want to change textColor in this panel you can create custom style with parent set to TextAppearance.Sherlock.Widget.PopupMenu and then change textColor property. Like this:
<style name="Widget.MyApp.ActionBarPopupLargeTextColor" parent="TextAppearance.Sherlock.Widget.PopupMenu.Large">
<item name="android:textColor">#color/black</item>
</style>
<style name="Widget.MyApp.ActionBarPopupSmallTextColor" parent="TextAppearance.Sherlock.Widget.PopupMenu.Small">
<item name="android:textColor">#color/black</item>
</style>
Worked for me :)

Here are the correct attrs to tune hardware menu style.
You should look at panelColorForeground ;-)
<item name="android:panelColorBackground">#FFFFFF</item>
<item name="android:panelColorForeground">#color/primary_text_holo_dark</item>
<item name="android:panelFullBackground">#drawable/menu_background_fill_parent_width_holo_dark</item>
<item name="android:panelTextAppearance">#style/Holo.TextAppearance</item>
Tested on HoloEverywhere lib and 2.3 emulator.
See attrs doc for details.

Related

Android override all button styles except dialogs

I've been overriding the default button style in my app like this:
<style name="ButtonStyle" parent="Base.Widget.AppCompat.Button">
<item name="android:textAllCaps">false</item>
<item name="android:textSize">18sp</item>
<item name="android:textColor">#color/primaryTextContrast</item>
<item name="android:background">#drawable/button</item>
</style>
That worked fine until Nougat, but with Nougat there's been a change (a bug fix I think) such that this style also applies to buttons in dialogs, while in previous versions it did not. This has the effect of giving the dialog buttons white text on a white background.
In case it's relevant, button is a 9 patch in drawable and is overridden in drawable-v21:
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="?attr/colorControlHighlight">
<item android:drawable="?attr/colorPrimary"/>
</ripple>
The primary color is dark, and primaryTextContrast is white. Dialogs do not get dark buttons in Nougat for some reason - they seem to pick up the text color but not the background. So I need to either let the dialog buttons do their default thing, or make the buttons fully inherit the style with a dark background and white text.
#nasch, Dialog buttons use button bar style. In this scenario, you could do something like
<style name="buttonBarButtonStyle" parent="Widget.AppCompat.Button.ButtonBar.AlertDialog">
<item name="android:textColor">#color/colorPrimary</item>
</style>
In your main style definition, you then define
<style name="MyCustomTheme" parent="Theme.AppCompat">
<item name="buttonBarButtonStyle">#style/buttonBarButtonStyle</item>
...
Hope this helps.

Overwrite default list view highlighted color in AppCompat theme

My application's main theme inherits from Theme.AppCompat, and I've created a selector that allows for the Ripple effect to take place when you press and focus a button on Lollipop.
However, when I go back to a 4.0 device, it defaults back to an ugly blue color when I focus a list view item. I've looked everywhere for the trait that defines this color hoping to override it without any luck - any idea how I can do this?
Add this to your theme:
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
...
<item name="android:listViewStyle">#style/ListViewAppTheme</item>
<item name="android:listViewWhiteStyle">#style/ListViewAppTheme.White</item>
</style>
<style name="ListViewAppTheme" parent="Base.Widget.AppCompat.ListView">
<item name="android:listSelector">#drawable/abc_list_selector_dark</item>
<item name="android:divider">#drawable/ab_divider_light</item>
<item name="android:dividerHeight">1px</item>
</style>
<style name="ListViewAppTheme.White" parent="Base.Widget.AppCompat.ListView.White">
<item name="android:listSelector">#drawable/abc_list_selector_dark</item>
<item name="android:divider">#drawable/ab_divider_light</item>
<item name="android:dividerHeight">1px</item>
</style>
Change #drawable/abc_list_selector_dark to whatever selector you want to use. As an added bonus, I added how to change the listview's divider and its height.
Unfortunately doesn't seem to be working. The list views still seem to
be getting that disgusting default blue color from SOMEWHERE, although
I can't figure out where.
I used to feel like you, both on the disgusting and the angry somewhere part. However I managed to get rid of it.
If I remember well, the culprit should be android:listChoiceBackgroundIndicator. Try this:
<style name="MainTheme" parent="Theme.AppCompat">
<item name="android:listChoiceBackgroundIndicator">#drawable/my_selector</item>
<item name="listChoiceBackgroundIndicator">#drawable/my_selector</item>
</style>

Actionbarsherlock - Color of Textselection Buttons

In my TextView I enabled text-selection with android:textIsSelectable.
The problem is, that the appearing actionbar is white and the color of the buttons (copy , select, etc.) is white too. (I use actionbarsherlock 4.4.0)
Is there a possibility to change the color of these items in the styles.xml and if yes: What is the correct way?
Edit:
I found out that i can customize the ActionMode Tab using:
<style name="MyCustomTheme" parent="#android:style/Theme.Holo.Light">
<item name="android:actionModeBackground">#color/color1</item>
<item name="android:actionModeSplitBackground">#color/color1</item>
</style>
But i am not able to change the color of the buttons

Light.DarkActionBar menu item text colour unchangeable?

The application I've been developing uses ActionBarSherlock, and the main theme inherits from Theme.Sherlock.Light.DarkActionBar. The design requires that the overflow menu popups have a dark coloured background and white text. This works fine for devices without a physical menu button, and the text appears white as intended. However, if the device DOES have a physical menu button, the text shown in the menu displayed remains black.
My main theme contains
<item name="android:panelBackground">#drawable/menu_hardkey_panel</item>
...Where #drawable/menu_hardkey_panel is a dark coloured 9patch.
The resulting appearance of the menu popup is...
I'm unable to determine why this is happening, or how to manually change the colour of the text. In my main theme, I've tried all of the following...
<item name="android:actionMenuTextColor">#android:color/white</item>
<item name="android:textAppearanceLargePopupMenu">#style/MyMenuTextAppearance.Large</item>
<item name="android:textAppearanceSmallPopupMenu">#style/MyMenuTextAppearance.Small</item>
I've even tried
<item name="android:actionBarWidgetTheme">#style/Theme.MyApp.Dark</item>
...Where Theme.MyApp.Dark is...
<style name="Theme.MyApp.Dark" parent="#style/Theme.Sherlock">
<item name="android:dropDownListViewStyle">#style/DropDownListView</item>
<item name="dropDownListViewStyle">#style/DropDownListView</item>
</style>
None have let me change the text to white. If I make my base theme inherit from Theme.Sherlock, the problem is solved and the text is white, but unfortunately that's not an option.
Not entirely sure about this, but I believe the pop-up menu uses the same styling as the overflow menu. In which case you'd just do something like this.
<item name="android:itemTextAppearance">#style/your_new_text_appearance</item>
<style name="your_new_text_appearance">
<item name="android:textColor">#android:color/white</item>
</style>
Giving it a chance: there is a text appearance called actionMenuTextAppearance. Have you tried that?
Update: I did some more digging and I believe that this file is the layout And there they refer to textAppearanceListItemSmall and textAppearanceSmall. However, it takes this value from a special theme which is specified as following in Theme.Holo.Light
<item name="panelMenuListTheme">#android:style/Theme.Holo.Light.CompactMenu</item>
And like this in Theme.Holo:
<item name="panelMenuListTheme">#android:style/Theme.Holo.CompactMenu</item>
The problems comes from the fact that the parent of Sherlock.__Theme.DarkActionBar is Theme.Sherlock.Light. This is not valid for the dark action bar. Taking the line from Theme.Holo should do the trick.
In my research I haven't found a way to change the text color, but you can at least handle hardkey menus gracefully.
This link provided me with a passable solution to the problem:
https://github.com/jgilfelt/android-actionbarstylegenerator/issues/30
Commenting out the "android:panelBackground" item from my generated theme allowed the text to at least be visible on hardkey menus, even if it doesn't perfectly match the theme.
You could also try replacing the "menu_hardkey_panel_whatever.9.png" drawable with something that will work for your theme and the black text.
For me this solves the problem, try this instead:
<style name="MyTheme" parent="Theme.Sherlock.Light.DarkActionBar">
...
<item name="actionBarWidgetTheme">#null</item>
<item name="android:actionBarWidgetTheme">#null</item>
...
</style>
I found the solution, use:
getSupportActionBarContext()
e.g.
ArrayAdapter<CharSequence> list =
ArrayAdapter.createFromResource(getSupportActionBarContext(), R.array.navigation, layout.simple_spinner_item);
list.setDropDownViewResource(layout.simple_spinner_dropdown_item);
getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
getSupportActionBar().setListNavigationCallbacks(list, this);
I think that due to the fact that Theme.Sherlock.Light.DarkActionBar don't style its contents right is due to the actionWidgetTheme attribute is used with a ContextThemeWrapper for inflating the action bar views (Jake Wharton's own words), thus something like the following (not tested) will be needed to fulfill your needs, though breaking your need of not using Theme.Sherlock as parent in one way:
<style name="MyColorTheme" parent="Theme.Sherlock">
<item name="android:actionMenuTextColor">#android:color/white</item>
<item name="actionMenuTextColor">#android:color/white</item>
</style>
<style name="YourMainTheme" parent="Theme.Sherlock.Light.DarkActionBar">
<item name="android:actionMenuTextAppearance">#style/MyColorTheme</item>
<item name="actionMenuTextAppearance">#style/MyColorTheme</item>
</style>
Might work or not work. That's the question :)

Setting Application theme textColor to white causes Context Menu item text to be white (invisible)

Ok, this is driving me bonkers. To skin my app, I set the following in my theme:
<item name="android:textColor">#FFFFFF</item>
All the text in the app turns white, unless I manually override it in the layout xmls. Great, yay, easy peasy. EXCEPT that the text in my menu options for context menus (off of lists and such) have also decided to become white.
This is not so great, since it is hard to read white on white. I have tried a variety of solutions, including searching for how to change the text color of a context menu (no dice)and creating a textAppearance item in my theme. The last solution didn't change all the textfields in my app, which was frustrating.
So, any suggestions? Hopefully my dilema is clear.
In your styles.xml try overriding the textViewStyle instead of just ALL textColor attributes:
<style name="Theme.Blundell.Light" parent="#android:style/Theme.NoTitleBar">
<item name="android:windowBackground">#drawable/background_light</item>
<item name="android:textViewStyle">#style/Widget.TextView.Black</item>
</style>
<style name="Widget.TextView.Black" parent="#android:style/Widget.TextView">
<item name="android:textColor">#000000</item>
</style>
You could even take it one further and just override the color for a certain view, like buttons:
<style name="Widget.Holo.Button" parent="#android:style/Widget.Holo.Button">
<item name="android:textColor">#FFFFFF</item>
</style>
<style name="Theme.Blundell" parent="#android:style/Theme.Holo.NoActionBar">
<item name="android:colorBackground">#android:color/transparent</item>
<item name="android:buttonStyle">#style/Widget.Holo.Button</item>
</style>
If your inspired to do any more theming check out the Android source it's the best place to realise what you can and can't do!:
https://github.com/android/platform_frameworks_base/tree/master/core/res/res/values
Use this:
parent="Theme.AppCompat.Light.DarkActionBar"

Categories

Resources