RecyclerView中EditText点击弹出软键盘后焦点丢失

破问题在网上找了很多帖子都没解决,但是我另外一个界面就一点事没有,因为我的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>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值