Change EditText long click menu text color - android

For some reason the menu that comes up on long click (for copy/paste/cut/etc...) in my EditText have white text color on a white background so it's unreadable.
I searched quite a lot on this forum but haven't found answer that would have worked so far, I have also tried adding a custom popup style for the base theme as well as for the EditText style with colorAccent, color and textColor changed, like this:
<style name="Base.AppTheme" parent="Theme.AppCompat.NoActionBar">
<!-- Tried all 3 separately -->
<item name="android:popupMenuStyle">#style/CustomPopup</item>
<item name="popupMenuStyle">#style/CustomPopup</item>
<item name="popupTheme">#style/CustomPopup</item>
</style>
<style name="Style.Input.EditText" parent="Widget.AppCompat.EditText">
<!-- Tried all 3 separately -->
<item name="android:popupMenuStyle">#style/CustomPopup</item>
<item name="popupMenuStyle">#style/CustomPopup</item>
<item name="popupTheme">#style/CustomPopup</item>
</style>
<style name="CustomPopup" parent="Widget.AppCompat.Light.PopupMenu">
<item name="android:colorAccent">#000000</item>
<item name="android:color">#000000</item>
<item name="android:textColor">#000000</item>
</style>
Unfortunately it did not work.
Does anyone know of a way to customise this menu, the text color in particular?

Check the theme style
<item name="android:background">#FFFFFF</item>
It's highly likely that you have it set to WHITE and the text is already being set to WHITE. I would comment out this line where you're setting the background color and see if you can't figure it out from there. This was my issue.

Related

How to change the header text color of my settings?

wallpicker app
I was actually trying to make an overlay theme that override my settings and other apps, I've somehow successfully make it transparent and change the font color but one thing i couldn't change is the header of it, in the image you'll see a "Settings" which isn't white color, that's my current problem, it also happened on other header apps just like "wallpaper picker app" and more apps
Already tried:
<item name="android:colorBackground">#android:color/primary_dark_device_default_settings</item>
<item name="android:windowBackground">#40000000</item>
<item name="android:windowShowWallpaper">true</item>
<item name="android:textColor">#ffffff</item>
adding a textColor but it didn't change the header text color or was it called an action bar?
also textColorPrimary doesn't do anything at all? and im on api 33
https://i.stack.imgur.com/3jsNN.jpg
https://i.stack.imgur.com/0Jsly.png
Try this.. In your original theme
<style name="Theme.MyApplication" parent="Theme.MaterialComponent.DayNight.NoActionBar">
<item name="toolbarStyle">#style/CustomToolbar</item>
</style>
your theme settings as follow:
<style name="CustomToolbar" parent="#style/Widget.MaterialComponents.Toolbar">
<item name="android:textColorPrimary">#android:color/white</item>
<item name="android:textColorSecondary">#android:color/white</item>
</style>

How can I change DatePickerDialog Header color background with my own customization? [Not Solved]

NOTE: This answer is not accurate. The problem in that accepted answer is it changes the footer color also.
I just want to change header color to black.
Please Note: Other things should not be change. For button, I sat button color programatically, which is perfect and date selected circle background color also should not be changed. Becasue I'm trying from last 6 hrs, but no luck.
I'm trying on 6.0.1
Code:
<style name="dialog_picker_theme" parent="Theme.AppCompat.DayNight.Dialog">
<item name="android:background">#303030</item>
<item name="android:textColorSecondary">#FFFFFF</item>
<item name="android:textColorPrimary">#FFFFFF</item>
<item name="colorAccent">#424242</item>
<item name="android:datePickerStyle">#style/MyDatePickerStyle</item>
</style>
<style name="MyDatePickerStyle" parent="#android:style/Widget.Material.Light.DatePicker">
<item name="android:headerBackground">#000000</item> <!-- header background color -->
</style>
And, I use this theme (dialog_picker_theme) in my datapickerdialog.
Apply preferred header color to the attribute android:textColorPrimaryInverse on your app's Base Application Theme:
<item name="android:textColorPrimaryInverse">#color/colorPrimary</item>

android - styling submenu triangle icon

I can't seem to find the correct area to style the little triangle icon on my submenu. I want it to be white in color but everything I try seems to make it colored black.
it looks like this style node of the main theme affects the color of the submenu arrow/triangle:
<item name="android:textColorPrimary">#android:color/black</item>
so changing this to color/white has changed the arrow to white - but any other default text must be manually set to black now.
EDIT: I solved this a better way that doesn't effect the rest of the text color in the activity styled.
in my main theme, i defined actionBarStyle:
<item name="actionBarStyle">#style/MainActActionBar</item>
then I define:
<style name="MainActActionBar" parent="Widget.AppCompat.Light.ActionBar.Solid.Inverse" >
<item name="popupTheme">#style/MainActionBarMenu</item>
</style>
and lastly:
<style name="MainActionBarMenu" parent="Widget.AppCompat.Light.PopupMenu.Overflow" >
<item name="android:textColorPrimary">#android:color/white</item>
</style>
this gives me the white arrow i was looking for and doesn't change anything else.
copy this line in your style that you have choosen.
<item name="subMenuArrow">#style/MyStyle</item>
and define Mystyle like this in your style.xml file
<style name="MyStyle" parent="Widget.AppCompat.ListMenuView">
<item name="color">#android:color/white</item>
<item name="android:textColorSecondary">#android:color/white</item>
</style>

Android - Change text colour of the bottom button bar

I'm modifying downloads (for 4.3 Jellybean) and I can't change the colour of the text on the bottom button from black to white. Is it possible to change the text colour without giving the button its own style by adding an item in the app theme? Here is my Styles.xml:
<style name="DownloadListTheme" parent="#android:style/Theme.DeviceDefault.Light.DialogWhenLarge">
<item name="android:textAlignment">viewStart</item>
<item name="android:layoutDirection">locale</item>
<item name="android:actionBarStyle">#android:style/Widget.DeviceDefault.Light.ActionBar.Solid.Inverse</item>
<item name="com.sonyericsson.uxp:extendedLookAndFeel">true</item>
<item name="android:textColor">#android:color/white</item>
</style>
Yes, you can accomplish this pretty easily, just override your theme in styles.xml like this:
<style name="MyButtonStyle"
parent="#android:style/Theme.DeviceDefault.Light.DialogWhenLarge">
<item name="android:textColor">#android:color/white</item>
</style>
For more information, see the documentation.

Styling ActionBar dropdown menu

I'm using a custom theme that inherits from DarkActionBar and I want to customize dropdown menu to be white like when using Light Holo theme.
I've been able to change the background to white using:
<style name="MyTheme" parent="#style/Theme.Light.DarkActionBar">
<item name="android:actionDropDownStyle">#style/MyDropDownNav</item>
</style>
<style name="MyDropDownNav">
<item name="android:background">#drawable/spinner_background_white</item>
<item name="android:popupBackground">#drawable/menu_dropdown_panel_whyite</item>
<item name="android:dropDownSelector">#drawable/selectable_background_white</item>
</style>
But I haven't any clue of how to change the text color to black. Because after setting white drawable the problem is that text isn't visible because is white on white background.
I answer myself after some investigation.
In addition to question's styling you need to:
Customize android:spinnerDropDownItemStyle for actionBarWidgetTheme changing it's text appearance.
Also don't forget that dropdown list is managed by the adapter you use. Then if you used the standard one (simple_dropdown_item_1line) there's no problem. But if you used a custom one like me (to be able to add an icon) don't forget to apply style="?attr/spinnerDropDownItemStyle" in your layout TextView.
Then final custom style is:
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="Theme.myapp" parent="#style/Theme.Light.DarkActionBar">
<item name="android:actionDropDownStyle">#style/myapp_DropDownNav</item>
<item name="android:actionBarWidgetTheme">#style/myapp.actionBarWidgetTheme</item>
</style>
<style name="myapp.actionBarWidgetTheme" parent="#style/Theme.">
<item name="android:spinnerDropDownItemStyle">#style/myapp.Widget.DropDownItem.Spinner</item>
</style>
<style name="myapp_DropDownNav" parent="#style/Widget.Spinner.DropDown.ActionBar">
<item name="background">#drawable/spinner_background_ab_myapp</item>
<item name="android:background">#drawable/spinner_background_ab_myapp</item>
<item name="android:popupBackground">#drawable/menu_dropdown_panel_myapp</item>
<item name="android:dropDownSelector">#drawable/selectable_background_myapp</item>
</style>
<style name="myapp.Widget.DropDownItem.Spinner" parent="Widget.DropDownItem.Spinner">
<item name="android:textAppearance">#style/myapp.TextAppearance.Widget.DropDownItem</item>
</style>
<style name="myapp.TextAppearance.Widget.DropDownItem" parent="TextAppearance.Widget.DropDownItem">
<item name="android:textColor">#color/black</item>
</style>
Where drawables in myapp_DropDownNav are white background ones that you can generate with ActionBar Style generator in Android Asset Studio
Try setting itemTextAppearance. That should achieve what you want.
I have stumbled on what may be the simplest way to do this. I was working with the AppCompat library.
<style name="ApplicationTheme" parent="#style/Theme.AppCompat">
<item name="android:actionBarWidgetTheme">#style/Theme.AppCompat.Light</item>
<item name="actionBarWidgetTheme">#style/Theme.AppCompat.Light</item>
</style>
My advice is to simply inherit from the Sherlock.Light theme and change the applicable fields to the Dark values. For my app, we wanted a white "up" icon, and white text for the action labels. I don't provide dark versions of my actionbar icons, so they are all white anyway. So after several hours messing around with it and following different people's suggestions, I finally found what I was looking for in the ABS themes file.
I inherit from Sherlock.Light (well, technically HoloEverywhereLight.Sherlock but...) and change:
<item name="android:actionMenuTextColor">#color/White</item>
<item name="actionMenuTextColor">#color/White</item>
<item name="android:homeAsUpIndicator">#drawable/abs__ic_ab_back_holo_dark</item>
<item name="homeAsUpIndicator">#drawable/abs__ic_ab_back_holo_dark</item>
<item name="android:dividerVertical">#drawable/abs__list_divider_holo_dark</item>
<item name="dividerVertical">#drawable/abs__list_divider_holo_dark</item>
That's it. It's way simpler and easier than trying to extend classes, restyle things in code, etc.

Categories

Resources