问题
I have the following in my styles.xml
<style name="dialog_style" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="colorAccent">#ffaaaa00</item>
<item name="android:background">#ff444400</item>
<item name="android:textColorPrimary">#ffa25600</item>
</style>
(The horrible colours are for testing only!)
This gives the following
What I want is a dark/black background but when I do that, the text is unreadable.
Q: How do I change the text colour of "Cut", "Copy"...?
tia, Kevin
回答1:
You can change them by following style names:
<item name="colorAccent">@color/twoCuteSelectionHandlersColor</item>
<item name="android:textColorHighlight">@color/selectionColor</item>
Also you can set highlight color directly for pacific EditText
using android:textColorHighlight
attribute in xml layout or programmatically:
et.setHighlightColor(color);
For context menu you need create your own context menu. check this question for how disabling default context menu and implementing custom menu.
回答2:
This isn't really an answer. The black-on-black edit menu is only generated from an EditText contained in an AlertDialog. The same code in a Fragment gives black-on-white.
So I "solved" my problem by converting the AlertDialog into a Fragment.
The original question, though, is still unanswered.
回答3:
Alert Dialog and Popup Menu generaly take the color of @ColorAccent as the background. So try changing the colorAccent or just inflate a custom xml with the specifications you want.
回答4:
Just change the parent of it from Theme.Material.Light to Theme.Material . It will make the text white, there.
回答5:
I fixed it by setting a background color with opacity in the style of the alertdialog
In styles.xml
<style name="AppCompatAlertDialogStyle">
...
<item name="android:background">@color/black_overlay</item>
...
</style>
In colors.xml
<color name="black_overlay">#66000000</color>
回答6:
I think it's a little bit better solution than user3247782's,
<style name="CustomAlertDialog" parent="Theme.AppCompat.Light.Dialog.Alert">
...
<item name="android:popupBackground">@android:color/transparent</item>
</style>
来源:https://stackoverflow.com/questions/45766210/how-to-change-to-text-colour-of-the-cut-copy-paste-popup-menu