Change the color of the cursor of an EditText in Android across all the sdk

前端 未结 5 2393
半阙折子戏
半阙折子戏 2021-02-19 08:30

Want to change the android\'s edittext cursor color, that has to be worked on across all the devices

5条回答
  •  佛祖请我去吃肉
    2021-02-19 08:59

    The way to get it across all platforms is as such.

    1 - Open your layout.xml in your layout folder. Find the edit text and set

    android:cursorVisible="true"
    

    this will set the cursor for devices lower that os version 11

    2 - Create your cursor_drawable.xml in the drawable folder

    
    
        
        
    
    

    3 - Create a folder layout-v11

    4 - Copy your layout.xml into the layout-v11

    5 - Find your edit text and set android:textCursorDrawable="@drawable/cursor_drawable"

    This will make a cursor be shown on all devices and OS.

提交回复
热议问题