更改EditText setError drawable gravity

ida*_*kav 8 android right-to-left android-edittext

对于将用RTL文本填充的EditText,有没有办法改变错误drawable的强度(当然还有弹出窗口)?

这是一个常规错误drawable的例子

错误绘制总是正确的

因为输入的文本是RTL,我希望弹出窗口显示在EditText的左侧

我试图应用自定义drawable,但Drawable似乎没有任何setGravity方法.

提前致谢.

Edw*_*aak 1

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);
Run Code Online (Sandbox Code Playgroud)

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"
/>
Run Code Online (Sandbox Code Playgroud)

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