MeesterPatat
MeesterPatat

Reputation: 2811

Android show EditText.setError() above the EditText and not below it

When i call EditText.setError(); the error appears below the edittext, and makes it impossible to interact with the View below the EditText. Is it possible to show the error above the EditText? Google doesn't seem to have the answer(Or i'm using wrong search terms).

https://i.sstatic.net/D1Uth.png

Upvotes: 15

Views: 3874

Answers (2)

user543
user543

Reputation: 3633

For this you have to take one textview with custom background above the 1st edittext and align_parent_right=true. Rather than setting setError() to edittext set the visibility(visible/invisible) to the textview. For that red drawable placed at right side in edittext, u can set drawableRight to edittext with setCompoundDrawablesWithIntrinsicBounds() method.

Upvotes: 0

bibi_bryan
bibi_bryan

Reputation: 371

The Crouton Library seems to be a better way to display errors when validating forms. See some reasons here

Upvotes: 1

Related Questions