当我触摸ListView或RecyclerView内的EditText时,显示软键盘.然后我点击键盘上的下一个按钮,焦点变为下一个EditText.在最后一个可见的EditText之后,焦点变为下一个EditText但ListView或RecyclerView没有在里面滚动,所有屏幕都在状态栏下每个键盘下一个Button点击.
以下用于此屏幕的xml:
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <include android:id="@+id/MainToolbar" layout="@layout/toolbar" /> <include android:id="@+id/llHeaderItem" layout="@layout/TaskShelfShareHeaderItem" /> <ListView android:id="@+id/lwShelfShare" android:layout_width="match_parent" android:layout_height="match_parent" android:stackFromBottom="true" android:transcriptMode="normal" /> </LinearLayout>
解决方法
我这样想了.希望能帮助到你.
mEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v,int actionId,KeyEvent event) { RecyclerView recyclerView = getRecyclerView(); if (recyclerView != null) { int position = getLayoutPosition(); RecyclerView.ViewHolder viewHolder = recyclerView.findViewHolderForLayoutPosition(position + 1); if (viewHolder == null) { recyclerView.smoothScrollToPosition(position + 1); return true; } } return false; } });