如何更改复制文本时出现的文本选择工具栏颜色? [英] How to Change the Text Selection Toolbar color which comes when we copy a text?
问题描述
我正在开发一个应用程序,并为 TextViews 设置了android:textIsSelectable".
I am developing an application and i set "android:textIsSelectable" for the TextViews.
但我的材质主题与 TextSelection appBar 不匹配.有没有办法改变那个appBar的颜色??
But my material theme is not matching with the TextSelection appBar. Is there a way by which i can change the color of that appBar ??
附上下面的图片检查它:-
Attached the Image Below Check it :-
推荐答案
假设您使用 appcompat-v7
库,请将这些添加到您的主题中:¨
Assuming you use the appcompat-v7
library add these to your theme:¨
<!-- this makes sure the action mode is painted over not above the action bar -->
<item name="windowActionModeOverlay">true</item>
<item name="actionModeBackground">@drawable/myapp_action_mode_background</item>
现在我无法设置动作模式的内部样式(文本颜色、图标颜色),所以希望您不需要.
Now I wasn't able to style the insides of the action mode (text color, icon colors) so hopefully you won't need to.
注意:如果您不使用支持库,请在这些样式项目名称前添加 android:
.这些将在 API 11+ 以上运行.
Note: If you don't use the support library prepend those style item names with android:
. These will work above API 11+.
编辑
对于带有笔划的动作模式背景,创建一个新的可绘制对象并更新参考.可绘制对象可能如下所示:
For an action mode background with a stroke create a new drawable and update the reference. The drawable could look like this:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:top="-2dp" android:left="-2dp" android:right="-2dp">
<shape android:shape="rectangle">
<solid android:color="@color/primary_dark"/>
<stroke android:color="@color/accent" android:width="2dp"/>
</shape>
</item>
</layer-list>
这篇关于如何更改复制文本时出现的文本选择工具栏颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!