破问题在网上找了很多帖子都没解决,但是我另外一个界面就一点事没有,因为我的RecyclerView是在NestedScrollView下的,所以就试着给它包了一层布局,里面只有RecyclerView(之前在ConstraintLayout下面,里面还有其他控件),这次运行后没问题了。
最后反思了一下,应该是ScrollView导致的焦点冲突,软键盘弹起后焦点回到了RecyclerView父布局也就是ScrollView身上,但把RecyclerView额外包裹一层后RecyclerView的父布局就不再是ScrollView了。
附上布局
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:padding="@dimen/twelve">
<TextView
android:id="@+id/question_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/twelve"
android:text="啊啊"
android:textColor="@color/mine_tablayout_text_blue"
android:textSize="@dimen/small_text"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/question_mark"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/three"
android:text="啊啊啊啊"
android:textColor="@color/mine_tablayout_text_blue"
android:textSize="@dimen/small_text"
android:visibility="gone"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@+id/question_text" />
<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="@+id/question_mark"
app:layout_constraintStart_toStartOf="@+id/question_text"
app:layout_constraintTop_toBottomOf="@+id/question_text">
<android.support.v7.widget.RecyclerView
android:id="@+id/question_options"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</RelativeLayout>
</android.support.constraint.ConstraintLayout>
</android.support.v4.widget.NestedScrollView>