androidbackgroundandroid-edittext

Change Android EditText background color


I am developing an Android app. There's this issue with the EditTexts, because in some devices the "background" is white (which is the way I want it), but on others is transparent, and makes the app less professional. Here's an image with the "white background":

enter image description here

On other devices the edit texts that say "Yo" and "Casa" are transparent, so the words mix with the map and its pretty awful.
I have tried changing the background color in the android layout xml. The closest one was I believe @drawable/white, but slightly changes the position and size of the edit text, making them look like they're one and its even worst. Here is an example:

enter image description here
Is there a nice way to approach this problem? I read somewhere that an option was to add a white background image to the edit texts, but seemed like a lot of trouble.

UPDATE
I tried adding a background image, but its the same as changing the background color to any color using the android:background, the edit texts get like smaller or something. I added a blue "delimiter" to the image and this is the result:

enter image description here

But I want them like in the first picture, not so close one to another.

This would be the code of the edittext layout XML, the other one looks very similar. Only by adding the android:background tag changes from picture 1, to picture 3


Solution

  • Why don't you try setting the background of EditText programmatically?

    yourEditText.setBackgroundColor(Color.WHITE);
    

    or...

    yourEditText.setBackgroundColor(Color.parseColor("#ffffff"));