Android Question EditText Not Drawing Correctly

colboy

Member
Licensed User
Longtime User
I have two panels, one contains a large EditText and the other contains 2 small EditTexts and a CheckBox. I want to change the color of the EditTexts so run the following code in the Activity_Create:

B4X:
    Dim cd As ColorDrawable
    cd.Initialize(Colors.White,0)  'white background of text box
    edtNote.Background=cd
    edtInitials.Background=cd
    edtBarcode.Background=cd

When the program runs, the first, large EditText does not fill the width. If I click on it and slide my finger across, it then draws correctly.

Attached are two screen grabs. The first is the incorrect one, the second is how it should look.
Any ideas to correct this?

Thanks, Colin
 

Attachments

  • BarcodeCapture-01.png
    37.3 KB · Views: 218
  • BarcodeCapture-02.png
    37.3 KB · Views: 224

Cableguy

Expert
Licensed User
Longtime User
I don't get it, why create a colordrawable for a solid color (or even a semi-transparent)?
 
Upvote 0

colboy

Member
Licensed User
Longtime User
I don't get it, why create a colordrawable for a solid color (or even a semi-transparent)?
Solved. I think I copied some code to change the EditText background color, when I could do the same by doing

B4X:
edtBarcode.color=Color.White

So now that's fixed, shouldn't both methods work the same?
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
Nop, the colordrawable will retain the size of the first view it is used on, and when you set it to another view with a different size it won' automatically redraw. You may solve it by calling invalidate on the views to force the redraw
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…