How to Change the Text Selection Toolbar color whi

2020-02-10 14:26发布

I am developing an application and i set "android:textIsSelectable" for the TextViews.

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 :-

enter image description here

2条回答
2楼-- · 2020-02-10 14:37

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>
查看更多
够拽才男人
3楼-- · 2020-02-10 14:57

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.

查看更多
登录 后发表回答