How to Change the Text Selection Toolbar color which comes when we copy a text?

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-29 05:56:41

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.

Note: If you don't use the support library prepend those style item names with android:. These will work above API 11+.

EDIT

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>

In your resources styles.xml: "android:textColorHighlight"

<resources>
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
   <item name="android:textColorHighlight">@color/yellow</item>
</style>
</resources>

You can put in whatever color you choose and whatever parent theme you are using.

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