【发布时间】:2017-07-13 21:59:08
【问题描述】:
我的布局有问题。在布局中你可以找到很多EditText。 当我单击编辑文本时,会显示一个弹出对话框。但是当我离开输入时,光标停留在里面。
所有edittext都有这个设置:
editText.setFocusable(false);
editText.setClickable(true);
editText.setLongClickable(false);
editText.setTextIsSelectable(false);
<EditText
android:id="@+id/input"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableRight="@drawable/ic_close_black_24dp"
android:ems="10"
android:inputType="textPersonName" />
离开输入框时如何隐藏光标?
更新:
当我点击“RIGHT DRAWABLE”图标时出现问题。
public static boolean isDrawableClick(MotionEvent event, EditText editText, DrawablePositions drawablePosition) {
if (event.getAction() == MotionEvent.ACTION_UP) {
if (editText.getCompoundDrawables()[drawablePosition.position] != null && event.getX() >= (editText.getRight() - editText.getLeft() - editText.getCompoundDrawables()[drawablePosition.position].getBounds().width())) {
return true;
}
}
return false;
}
谢谢
【问题讨论】:
-
android:windowSoftInputMode="stateHidden. 试试这个
-
我试过了,还是不行
标签: android