• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

RecyclerViewEditText点击弹出软键盘后焦点丢失

武飞扬头像
枫林梦
帮助1

破问题在网上找了很多帖子都没解决,但是我另外一个界面就一点事没有,因为我的RecyclerView是在NestedScrollView下的,所以就试着给它包了一层布局,里面只有RecyclerView(之前在ConstraintLayout下面,里面还有其他控件),这次运行后没问题了。

最后反思了一下,应该是ScrollView导致的焦点冲突,软键盘弹起后焦点回到了RecyclerView父布局也就是ScrollView身上,但把RecyclerView额外包裹一层后RecyclerView的父布局就不再是ScrollView了。

附上布局

  1.  
    <android.support.v4.widget.NestedScrollView
  2.  
    android:layout_width="match_parent"
  3.  
    android:layout_height="match_parent">
  4.  
     
  5.  
    <android.support.constraint.ConstraintLayout
  6.  
    android:layout_width="match_parent"
  7.  
    android:layout_height="wrap_content"
  8.  
    android:background="@color/white"
  9.  
    android:padding="@dimen/twelve">
  10.  
     
  11.  
    <TextView
  12.  
    android:id="@ id/question_text"
  13.  
    android:layout_width="wrap_content"
  14.  
    android:layout_height="wrap_content"
  15.  
    android:layout_marginTop="@dimen/twelve"
  16.  
    android:text="啊啊"
  17.  
    android:textColor="@color/mine_tablayout_text_blue"
  18.  
    android:textSize="@dimen/small_text"
  19.  
    app:layout_constraintStart_toStartOf="parent"
  20.  
    app:layout_constraintTop_toTopOf="parent" />
  21.  
     
  22.  
    <TextView
  23.  
    android:id="@ id/question_mark"
  24.  
    android:layout_width="wrap_content"
  25.  
    android:layout_height="wrap_content"
  26.  
    android:layout_marginLeft="@dimen/three"
  27.  
    android:text="啊啊啊啊"
  28.  
    android:textColor="@color/mine_tablayout_text_blue"
  29.  
    android:textSize="@dimen/small_text"
  30.  
    android:visibility="gone"
  31.  
    app:layout_constraintEnd_toEndOf="parent"
  32.  
    app:layout_constraintTop_toTopOf="@ id/question_text" />
  33.  
     
  34.  
    <RelativeLayout
  35.  
    android:layout_width="0dp"
  36.  
    android:layout_height="wrap_content"
  37.  
    app:layout_constraintBottom_toBottomOf="parent"
  38.  
    app:layout_constraintEnd_toEndOf="@ id/question_mark"
  39.  
    app:layout_constraintStart_toStartOf="@ id/question_text"
  40.  
    app:layout_constraintTop_toBottomOf="@ id/question_text">
  41.  
     
  42.  
    <android.support.v7.widget.RecyclerView
  43.  
    android:id="@ id/question_options"
  44.  
    android:layout_width="match_parent"
  45.  
    android:layout_height="wrap_content" />
  46.  
     
  47.  
    </RelativeLayout>
  48.  
     
  49.  
    </android.support.constraint.ConstraintLayout>
  50.  
    </android.support.v4.widget.NestedScrollView>
学新通

这篇好文章是转载于:学新通技术网

  • 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
  • 本站站名: 学新通技术网
  • 本文地址: /boutique/detail/tanhhaaahh
系列文章
更多 icon
同类精品
更多 icon
继续加载