Edittext's default style

1

I have a EditText that looks like this:

When doing an action in EditText the background is changed with the following code:

edtCampo.setBackgroundColor(Color.RED);

Then another action is made and the background of EditText is changed again with the following code:

edtCampo.setBackgroundColor(Color.TRANSPARENT);

The problem is that in the EditText I do not see the line below, what property should I give ???

This is the EditText definition in the layout

and the style:

fill_parent wrap_content ? android: attr / textAppearanceLarge center_vertical | center_horizontal 10dp 10dp @ color / blue

    
asked by Sergio Andres Moreno Herrera 06.12.2017 в 23:52
source

2 answers

1

The reason why the underline does not appear is precisely because you define a Transparent background color:

edtCampo.setBackgroundColor(Color.TRANSPARENT);

I suggest adding the following color as backgroundTint and avoid using the transparent color:

android:backgroundTint="@android:color/holo_red_light"

with this you will have the following result:

To do the above programmatically it is done in this way, where #ffff4444 is the color corresponding to holo_red_light :

myEditText.getBackground().setColorFilter(Color.parseColor("#ffff4444"), PorterDuff.Mode.SRC_ATOP);

to obtain as a result:

    
answered by 07.12.2017 / 18:00
source
1

To change the lower "line" of color to be noticed when using the red background, you must change the colors or color, in your file colors.xml

The three colors you will find are generated automatically when you create a project

 <color name="colorPrimary">#00695c</color>
 <color name="colorPrimaryDark">#004D40</color>
 <color name="colorAccent">#fffff</color> // aquí cambias el color que quieras, en tu caso yo usaria un negro para que resalte en ambos casos.
    
answered by 07.12.2017 в 03:07