Romeu Fernandes
Romeu Fernandes

Reputation: 23

Change the color of the input line in the alert Dialog

I need to change the color of the edit text line, in the alert dialog, I'm trying everything, and I'm not working.

public void alertaComentario()
    {
        AlertDialog.Builder comentario = new AlertDialog.Builder(getActivity(), R.style.AppCompatAlertDialogStyle);
        comentario.setMessage("Escreva uma resenha curta");
        final EditText input = new EditText(getActivity());
        input.setInputType(InputType.TYPE_CLASS_TEXT);
        comentario.setView(input);

        comentario.setPositiveButton("Enviar", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                Toast.makeText(getActivity(), "A sociedade agradece seu comentário", Toast.LENGTH_SHORT).show();
            }
        });
        comentario.setNegativeButton("Cancelar", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.cancel();
            }
        });
        comentario.show();
    }

alert dialog

enter image description here

Upvotes: 1

Views: 1101

Answers (2)

Tara
Tara

Reputation: 700

in your Alert Dialog xml update EditText with this line:

 android:backgroundTint="#ffffff"

Upvotes: 0

user8650771
user8650771

Reputation:

The line in an editText is usually based on the ColorAccent in the colors.xml:

<resources>
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color> //Change this

If you change the color accent, it will change editText color.

Upvotes: 1

Related Questions