C colboy Member Licensed User Longtime User May 15, 2018 #1 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: Code: Copy 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: 442 BarcodeCapture-02.png 37.3 KB · Views: 383
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: Code: Copy 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
Cableguy Expert Licensed User Longtime User May 15, 2018 #2 I don't get it, why create a colordrawable for a solid color (or even a semi-transparent)? Upvote 0
M Mahares Expert Licensed User Longtime User May 15, 2018 #3 colboy said: Any ideas to correct this? Click to expand... When you are dealing with ColorDrawable, you need to create one colordrawable for each edittext especially when they are not the same width. No one size fits all. Upvote 0
colboy said: Any ideas to correct this? Click to expand... When you are dealing with ColorDrawable, you need to create one colordrawable for each edittext especially when they are not the same width. No one size fits all.
C colboy Member Licensed User Longtime User May 15, 2018 #4 Cableguy said: I don't get it, why create a colordrawable for a solid color (or even a semi-transparent)? Click to expand... Solved. I think I copied some code to change the EditText background color, when I could do the same by doing Code: Copy edtBarcode.color=Color.White So now that's fixed, shouldn't both methods work the same? Upvote 0
Cableguy said: I don't get it, why create a colordrawable for a solid color (or even a semi-transparent)? Click to expand... Solved. I think I copied some code to change the EditText background color, when I could do the same by doing Code: Copy edtBarcode.color=Color.White So now that's fixed, shouldn't both methods work the same?
Cableguy Expert Licensed User Longtime User May 15, 2018 #5 colboy said: Solved. I think I copied some code to change the EditText background color, when I could do the same by doing Code: Copy edtBarcode.color=Color.White So now that's fixed, shouldn't both methods work the same? Click to expand... 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
colboy said: Solved. I think I copied some code to change the EditText background color, when I could do the same by doing Code: Copy edtBarcode.color=Color.White So now that's fixed, shouldn't both methods work the same? Click to expand... 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
Erel B4X founder Staff member Licensed User Longtime User May 16, 2018 #6 You should never use the same drawable object with multiple views. Create a new drawable for each view. Upvote 0
You should never use the same drawable object with multiple views. Create a new drawable for each view.