Actionbarsherlock - Color of Textselection Buttons - android

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

Related

How to change title text and buttons color WITHOUT changing action overflow menu text color in new Toolbar?

I use android.support.v7.widget.Toolbar in my project. By default in light theme it has black action overflow menu icon, black title and black overflow menu text color, like that (don't look at the navigation icon - it's custom):
But in my App I need it to be white.
I set android:textColorPrimary to white in my styles for the toolbar:
<style name="Widget.My.Toolbar" parent="Widget.AppCompat.Toolbar">
<item name="theme">#style/ThemeOverlay.My.Toolbar</item>
</style>
<style name="ThemeOverlay.My.Toolbar" parent="ThemeOverlay.AppCompat.ActionBar">
<item name="android:textColorPrimary">#color/white</item>
</style>
It changed color of the title and the overflow menu button just like I wanted, but it changed Action owerflow menu items text color too:
It looks ugly.
I even tried set a Title color programmatically with
toolbar.setTitleTextColor(getResources.getColor(R.color.white);
but it changes ONLY Title color, and not changes menu button:
So how can I change color for everything in the toolbar, except items in action overflow menu?
After you set the text color for for your Toolbar you can set the text color of your menus with the following attribute:
<item name="actionMenuTextColor">#color/white</item>
Since you are using the AppCompat Toolbar the android namespace need not be included in the attribute, as shown above.
However, it seems people have had mixed experience with this. You can also try using the itemTextAppearance attribute:
<style name="yourTheme" parent="yourThemeParent">
<!-- Rest of your theme -->
<item name="android:itemTextAppearance">#style/menuItemColor</item>
</style>
<style name="menuItemColor">
<item name="android:textColor">#android:color/black</item>
</style>
I found that the first solution worked for me when I explicitly included a Toolbar in my layout, but not if I used getSupportActionBar() to get the default bar included in a given theme. However, in this scenario, the second solution did work for me.

ShareActionProvider Drop down menu color from AppCompat v7

Just tried ShareActinProvider from AppCompat v7 and while the drop down from the action bar menu is light and good, the drop down from the ShareActionProvider share button is dark.
This is the style applied.
<style name="Theme.Pinnr" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">#C62828</item>
<item name="colorPrimaryDark">#B71C1C</item>
</style>
I want both menus to have the same color.
Here is the bad menu image:
Here is the good menu image:
Update
I am in fact aware that I can change the color of that popup background with this code
<style name="Theme.Pinnr.listPopupWindowStyle" parent="Widget.AppCompat.Spinner.DropDown.ActionBar">
<item name="android:popupBackground">#eeeeee</item>
</style>
My question is why its happening and shouldn't just behave like the other menu. And hopefully how do I set it to match the other menu without hardcoding the color for the popup
Had the same issue and it was because I was based on Ligh.DarkActionBar theme. Changed to just the Light theme and it worked fine.

Change ActionBarCompat title color but not other texts color

I'm using last release of support library (V21) which include material themes (under Theme.AppCompat name) and I want to put ActionBar title in white. I tried to achieve it by using textColorPrimary (as it's shown there) attribut in my custom theme
<style name="AppBaseTheme" parent="#style/Theme.AppCompat.Light">
<item name="colorPrimary">#color/orange</item>
<item name="colorPrimaryDark">#color/orange_dark</item>
<item name="colorAccent">#color/white</item>
<!-- This attribut set text color -->
<item name="android:textColorPrimary">#color/white</item>
</style>
With this I got a white actionbar title but all other text (textview, edittext) were white too...
Is there a way to change only actionbar title color with recently released features or the only way is to use a custom style for action bar, just like it was the case with Holo ?
Use #style/Theme.AppCompat.Light.DarkActionBar to invert the text color only in the Action Bar.

ActionBarSherlock hardkey menu panel text color

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.

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 :)

Categories

Resources