Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change EditText setError drawable gravity

For EditText that going be filled with RTL text, is there a way to change the gravity of the error drawable (and popup of course) ?

here is an example of regular error drawable

error drawable always right

so since the text entered is RTL i would like the pop up to show up at the LEFT side of the EditText

i tried to apply custom drawable , but Drawable doesnt seem to have any setGravity method.

thanks in advance.

like image 764
idanakav Avatar asked Mar 02 '13 11:03

idanakav


1 Answers

It's not possible by normal means, however you can extend the Android TextView class and change the layout that Android uses to inflate the popup. I haven't tried this myself but it could work.

I did a quick look in the source of TextView and found this line

final TextView err = (TextView) inflater.inflate(com.android.internal.R.layout.textview_hint,
                   null);

Which references to this layout.

<TextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/popup_inline_error"
    android:textAppearance="?android:attr/textAppearanceSmallInverse"
/>

Adding gravity here could do the trick. A similar approach for the drawable could apply.

like image 102
Edward van Raak Avatar answered Oct 30 '22 01:10

Edward van Raak