Bug? EditText Color / TextColor

Computersmith64

Well-Known Member
Licensed User
Longtime User
I posted in the v3.20 BETA thread about the EditText not having its Color property available in the designer, so only being able to set the background color in code. Erel's reply was:

It is not possible to change the EditText color. You can do it with code but it will remove the nice background. The EditText background is actually a nine patch image.

At first I thought my problem with this is the way the EditText is displayed on different devices (or more likely, different Android versions). For example, on my Galaxy S3 (Android v4.3) EditTexts show up with a black background by default, but on my Nexus 7 (Android v4.4.2), the EditText background seems to be transparent. I thought this was an issue because if I use black text, then I can't see it on the Galaxy & if I use white text, then it doesn't show up on the Nexus if the EditText is on a white panel. "Easy" you say, "Just use the DEFAULT text color" - well read on...

I discovered that using DEFAULT text color (with the EditText on a white panel) works fine on the Galaxy (where the EditText background is black). However on the Nexus (where the EditText background is white), I have found what I think is a bug:

If the EditText is disabled (.Enabled = False), the text shows as black (or perhaps dark gray), however when I enable the EditText (.Enabled = True), the text color changes to the background color of the EditText - so is now not visible. This is the case whether the EditText is being edited or not.

If you look at the images you'll see what I mean:



Thanks - Colin.
 

Computersmith64

Well-Known Member
Licensed User
Longtime User
Not sure that I understand. Which one of the images shows the problem?

This one. The EditText is enabled & there is text in it, however you can't see it because the text color is the same as the background color (or perhaps the text is transparent?):

 

Computersmith64

Well-Known Member
Licensed User
Longtime User
I don't think that there is any bug here. The EditText is actually transparent. The default disabled color is white so it is difficult to see the color.

Note that you can use the UI Cloud to test the colors on multiple devices.

Erel,

In the image in the post above, the EditText is ENABLED. For clarity, here are the 2 images again:

DISABLED:


ENABLED:


There is definitely some kind of issue here. How can you enter text if you can't see what you are typing?

Thanks - Colin.
 

Computersmith64

Well-Known Member
Licensed User
Longtime User
OK - but why does the background color of the EditText change between v4.3 & v4.4? On v4.3 it's black & on v4.4 it's white (or is it transparent?). If I don't explicitly set the background & text color of the EditText, I have no way of knowing for sure if there will be a problem displaying text on different versions of Android.
 

Computersmith64

Well-Known Member
Licensed User
Longtime User
OK - so after scratching my head for a while & then reading Barx's excellent tutorial on version based themes, plus looking at the Android themes xml (https://android.googlesource.com/pl...s/heads/master/core/res/res/values/themes.xml), I figured out that if I put
B4X:
SetApplicationAttribute(android:theme, "@android:style/Theme.Holo")
into my manifest, I can set the EditText text color to black & get a consistent look across all devices without having to change the beckground color in code.

I still think that having a situation where using DEFAULT text color can result in the text color being the same color as the EditText background is a bug - if not in B4A, then in Android itself. Regardless of the theme, the DEFAULT text color should be visible.

Thanks - Colin.
 

Anuj_Singh

Member
Licensed User
Longtime User
I have same issue, actually I want to change EditText Backcolor as White.
I use EditText1.color = Colors.White
But it wont change any thing, it still shows black backcolor.
I am using Android 4.0.1
 

Anuj_Singh

Member
Licensed User
Longtime User
Yes,
I have put my controls on Panel and Panel color is white.
Also put EditText background as white image using following code

Dim cdb As ColorDrawable
cdb.Initialize(Colors.White , 5)
txtUserName.Background = cdb
Activity.AddView(txtUserName, 20dip, 91dip, 280dip, 40dip)

But it still show textbox as Black shade gray color.
Here I attach the screen shot of my Login Screen.
 

Attachments

  • loginScreen.png
    26.1 KB · Views: 510

Anuj_Singh

Member
Licensed User
Longtime User
It looks same as Panel is of White color.
Actually this application mostly use in the Sunlight that's why I want every thing as White and only Text as Black.
 

klaus

Expert
Licensed User
Longtime User
Try this code:
B4X:
Dim enabled1, disabled1 As ColorDrawable
enabled1.Initialize(Colors.Green, 10dip)
disabled1.Initialize(Colors.Red, 10dip)

Dim sld As StateListDrawable
sld.Initialize
sld.AddState(sld.State_Enabled, enabled1)
sld.AddState(sld.State_Disabled, disabled1)
edtTest1.Background = sld
The 'strange' colors are for testing .
 

Anuj_Singh

Member
Licensed User
Longtime User
Klaus,
As I put white color as background, my Emulator shows cursor in it.
But my mobile device which has Android 4.0 wont shows Cursor.

Any Idea about it ?
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…