2

How can i create a cursor similar to the image which have different textcolor

Vishnu V S
  • 320
  • 1
  • 9

3 Answers3

2

Try something like this:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
    <solid android:color="#00ff00"/>
    <size android:width="1dp"/>
</shape>

EditText in layouts.

<?xml version="1.0" encoding="utf-8"?>
<EditText xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textCursorDrawable="@drawable/greencursor"
         >
    </EditText>
Krupa Patel
  • 3,163
  • 3
  • 19
  • 27
2

What about the styles.xml ?

<item name="colorControlNormal">@color/accentColor</item>
<item name="colorControlActivated">@color/accentColor</item>
<item name="colorControlHighlight">@color/accentColor</item>
Waqar ul islam
  • 358
  • 1
  • 15
  • http://stackoverflow.com/questions/11649234/change-edittext-cursor-color you are just copy and pasted the code :) – Vaisakh Apr 24 '15 at 07:52
0

Set android:textCursorDrawable to @null like,

android:textCursorDrawable="@null"

Now your EditText Cursor is same as your EditText TextColor.

UPDATE:

Then you can use the property: android:textColor to set the color you want for your cursor.

Reference: Set EditText cursor color.

Community
  • 1
  • 1
My God
  • 21,961
  • 23
  • 93
  • 166