Android Question Make Edittext cursor more visible[Solved]

Roger Daley

Well-Known Member
Licensed User
Longtime User
Hi All,

A very generalised question. The cursor in Edittext is not easily seen, there have been numerous posts to change colour, blink rate, size etc. I think I have tried them all, none really work. EG Some years ago Erel provided me with a java sub to SHOWPINS. Still works well on my old Note 3 but not on devices running Android 8/9. This is common with other solutions.

My question: Does anyone have a way to make the cursor in an Edittext stand out?

More in hope than expectation......?

Regards Roger
 
Last edited:

Erel

B4X founder
Staff member
Licensed User
Longtime User


Manifest editor (based on: https://stackoverflow.com/questions...e-edit-text-cursor-color-and-width-in-android):
B4X:
CreateResource(layout, layout1.xml, 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:paddingLeft="16dp"
  android:paddingRight="16dp"
  android:orientation="vertical" >


   <EditText android:tag="EditText1"  android:id="@+id/edittext1"
  android:layout_width="match_parent" android:layout_height="wrap_content"
        android:textCursorDrawable="@drawable/my_custom_cursor_drawable"
     />
</LinearLayout>
)
CreateResource(drawable, my_custom_cursor_drawable.xml , 
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
<size android:width="5dp" />
<solid android:color="#FFFF0000"/>
</shape>
)

Code:
B4X:
    Dim x As XmlLayoutBuilder
    x.LoadXmlLayout(Activity, "layout1")
    Dim et As EditText = x.GetView("edittext1")
    et.RemoveView
    Activity.AddView(et, 20dip, 20dip, 200dip, 50dip)
 
Upvote 0

Roger Daley

Well-Known Member
Licensed User
Longtime User
Erel,

Thanks for the reply.
Which library do I need for XmlLayoutBuilder. It is throwing an Unknown Type warning.

Regards Roger

 
Last edited:
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…