Android Question EditText cursor color on Android 9+

jai

Active Member
Licensed User
Longtime User
How do I change the color of cursor for input in EditText. Prior Android versions work ok but the cursor is barely visible on white EditText box on recent versions of Androids. I have tried earlier posts on similar topic but none has produced desirable results.
Appreciate any help.
 

jai

Active Member
Licensed User
Longtime User
Thanks Erel!

Before I start making elaborate changes as per #1 let me run by you my needs again to be sure that your earlier suggestion is the right way to go.

I have many arrays of EditText boxes that are dynamically created to input data and perform associated computations for each input. I have been using the following to maintain a visible black cursor in each EditText
B4X:
Dim CursorColor As ViewSetting
CursorColor.setCursorDrawableColor(txt1(I),Colors.Black)
This is a simple passive setting that works fine for formatting textboxes for a visible black cursor on all devices tested until Android 7. What I am looking for is an equivalent that would also work on more recent versions of Android. I am hesitant to undertake more elaborate changes for the sake of a black cursor on some devices.

My text boxes are white and the theme is Holo
B4X:
SetApplicationAttribute(android:theme, "@android:style/Theme.Holo")
If there is no easy alternative could someone please post sample code to implement the modifications suggested earlier. Thanks.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
My text boxes are white and the theme is Holo
This is very bad. Why lock your app to such an old theme?

As far as I know the only way to change the cursor drawable is by loading it with XmlLayoutBuilder.
The real issue is the theme. Select the correct theme and everything will look fine.
 
Upvote 0

jai

Active Member
Licensed User
Longtime User
A change to a light Theme improved the cursor visibility markedly, nicely serving my purpose.

Thanks Erel for the guidance!
 
Upvote 0
Top