Все, у меня есть свиток, содержащий editText.scrollView.requestFocus() возвращает true, но он не работает
Как только я нажимаю на editText, он получает фокус и показывает SoftInput.
На мой взгляд, если я нажимаю пустое место, softintput hide и editText теряют фокус, а scrollview получает фокус.
Так что мой следующий код:
scrollView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
//call twice, once down, once up
if (event.getAction() == MotionEvent.ACTION_DOWN) {
if (activity.getCurrentFocus() != null && activity.getCurrentFocus().getWindowToken() != null) {
inputManager.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
scrollView.requestFocus();
activity.getCurrentFocus();
}
}
return false;
}
});
ScrollView
android:focusable="true"
android:focusableInTouchMode="true"
android:id="@+id/scrollView"
android:layout_below="@+id/topBar"
android:layout_marginTop="20dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
Но в конце концов, EditText еще фокус (activity.getCurrentFocus() == EditText), любые советы?
удалять фокус из текста редактирования программно. –
@MurtazaHussain Я использую 'activity.getCurrentFocus(). ClearFocus();', все равно ничего не произошло – Ninja