1

I have an EditText with italic hint and text. And I want to have italic cursor for it. How do I do that? I couldn't find any post about it in Stack Overflow. Can I do that without custom cursor drawable? In Microsoft Office when you select italic, the cursor automatically becomes italic. I want to have that italic cursor.

my EditText

amira
  • 416
  • 1
  • 7
  • 24
  • in the editText attributes for cursors, there's nothing other than android:textCursorDrawable that relates to your question. You'd need to have a custom drawable for a slanted cursor – Nikos Hidalgo Nov 17 '18 at 15:41
  • Whats the effect of `android:textStyle="italic"` on cursor ? – ADM Nov 17 '18 at 15:47
  • `android:textStyle="italic"` didn't have any effect. – amira Nov 17 '18 at 16:14

1 Answers1

0

You need to create drawable like this. Choose color u want and angle you want. "itlic_cursor.xml"

<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:viewportWidth="24"
    android:viewportHeight="24"
    android:width="30dp"
    android:height="30dp"></vector>

This is what I got. If u want to add another italic cursor, first get png or jpg image and convert it to SVG. Then convert that SVG to drawable using http://a-student.github.io/SvgToVectorDrawableConverter.Web/

then add it to edit text XML like below

android:textCursorDrawable="@drawable/itlic_cursor"
PushpikaWan
  • 2,437
  • 3
  • 14
  • 23
  • 1
    If you want drawable shape you can find line with angle https://stackoverflow.com/questions/15237582/how-rotate-line-in-android-xml here answer. If u can create what line u want using photoshop or what ever. It can be converted into vector drawable like i mentioned above – PushpikaWan Nov 17 '18 at 16:18
  • @Lucefer go for this link, you will get help : https://stackoverflow.com/questions/11554078/set-textcursordrawable-programmatically – Rishav Singla Nov 19 '18 at 11:06