Android 自定义错误弹出窗口背景
有没有办法为TextView中的错误弹出窗口设置自定义布局: .Android 自定义错误弹出窗口背景,android,popup,textview,Android,Popup,Textview,有没有办法为TextView中的错误弹出窗口设置自定义布局: . 在textView.setError(字符串,可绘制)中,我们只能设置错误图标。 TextView和ErrorPopup类中的showError()方法是私有的,因此我无法使用它们 有什么想法吗?提前谢谢!迈克尔 UPD: 感谢您的评论,但据我所知,主题技巧在这里不适用: (android-10上的TextView 3384行) 无效方向(上面的布尔值){ mAbove=以上; 如果(上文){ mView.setBackgroun
在
textView.setError(字符串,可绘制)
中,我们只能设置错误图标。
TextView和ErrorPopup
类中的showError()
方法是私有的,因此我无法使用它们
有什么想法吗?提前谢谢!迈克尔
UPD:
感谢您的评论,但据我所知,主题技巧在这里不适用:
(android-10上的TextView 3384行)
无效方向(上面的布尔值){
mAbove=以上;
如果(上文){
mView.setBackgroundResource(com.android.internal.R.drawable.popup\u inline\u error\u如上);
}否则{
mView.setBackgroundResource(com.android.internal.R.drawable.popup\u inline\u错误);
}
}
在android-15中,com.android.internal.R.styleable.Theme\u errorMessageBackground主题参数被使用,但它是内部的。因此,除了编写我自己的错误通知程序之外,我看不到任何解决这个问题的方法):也许你可以为它设置一个主题或样式。也许。在
TextView.bathror()中使用了com.android.internal.R.styleable.Theme\u errorMessageBackground,但我找不到可以在哪里更改此参数。有关主题的更多信息,此属性可能是textview的私有属性,但您可以尝试通过主题进行更改。您可能希望使用EditText的子类,该子类实现其自己的自定义错误消息布局。请看这里:
void fixDirection(boolean above) {
mAbove = above;
if (above) {
mView.setBackgroundResource(com.android.internal.R.drawable.popup_inline_error_above);
} else {
mView.setBackgroundResource(com.android.internal.R.drawable.popup_inline_error);
}
}