Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
440 views
in Technique[技术] by (71.8m points)

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

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...