How to change to text colour of the Cut/Copy/Paste popup menu

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-11 02:46:59

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!