Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change color / appearance of EditText select handle / anchor?

Tags:

So I changed the style of the Holo Theme with the Holo Colors Generator and Action Bar Style Generator to my own color. But when I select text inside an edit text, the "markers" at the selected positions are still blue. How can I change it?

LeftMiddleRight

like image 323
jimpic Avatar asked Feb 28 '13 11:02

jimpic


People also ask

How to change the color of an anchor tag in HTML?

When you create an anchor tag in HTML, which is a tag which directs a user to another web page, by default, the tag comes in a blue color. Below is an example of a common anchor tag you'd created which comes with this default color: Though this colors appear by default, it can be changed to any color which we want by using CSS.

How to change line color in edittext?

This example demonstrate about how to change line color in EditText. Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.

How to change the color of select handles in Android?

In order to change the color of select handles, you have to override the activated color in your app theme: <style name="MyCustomTheme" parent="@style/Theme.AppCompat.Light.NoActionBar"> <item name="android:colorControlActivated">@color/customActivatedColor</item> </style>

What is edittext in Android?

Android – EditText on text change EditText is used to read input from user. A listener could be attached to the EditText to execute an action whenever the text is changed in the EditText View.


2 Answers

The worst part here was to find the "name" for this item and how it is called inside the theme. So I looked through every drawable in the android SDK folder and finally found the drawables named "text_select_handle_middle", "text_select_handle_left" and "text_select_handle_right".

So the solution is simple: Add these drawables with customized design/color to your drawable folder and add them to your theme style definition like:

<style name="MyCustomTheme" parent="@style/MyNotSoCustomTheme">         <item name="android:textSelectHandle">@drawable/text_select_handle_middle</item>         <item name="android:textSelectHandleLeft">@drawable/text_select_handle_left</item>         <item name="android:textSelectHandleRight">@drawable/text_select_handle_right</item> </style> 
like image 92
jimpic Avatar answered Sep 24 '22 01:09

jimpic


I recognize this is really late, but if all you want to do is change the color of the handle, you just need to add the following to your styles.xml file.

<style name="ColoredHandleTheme">     <item name="colorControlActivated">@color/colorYouWant</item> </style> 

And then just set the theme on whatever activity is holding the EditText which you want to affect.

Or if you want to set it app-wide, you can do the following:

<style name="ColoredHandleThemeForWholeApp">     <item name="colorAccent">@color/colorYouWant</item> </style> 

And set that theme for the whole app.

Problem solved!

like image 25
LukeWaggoner Avatar answered Sep 25 '22 01:09

LukeWaggoner