问题描述
先决条件
main_layout.xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/swipeRefreshLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.core.widget.nestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbarFadeDuration="2"
android:scrollbars="vertical|horizontal">
<FrameLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</androidx.core.widget.nestedScrollView>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
recyclerview_layout.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<...>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusable="true"
android:focusableInTouchMode="true">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
</LinearLayout>
another_recyclerview_layout.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:divider="@drawable/divider_default_margin"
android:orientation="vertical"
android:showDividers="middle">
<...>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/anotherRecyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<...>
</LinearLayout>
edittext_item_layout.xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
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="wrap_content">
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/textInputLayout"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/formTextClearButton"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/textInput"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</com.google.android.material.textfield.TextInputLayout>
<...>
</androidx.constraintlayout.widget.ConstraintLayout>
问题描述
我在运行时将 recyclerview_layout.xml
添加到 container
内的 main_layout.xml
。 recyclerview_layout.xml
有时包含 another_recyclerview_layout.xml
,它有一个 RecyclerView
,该 edittext_item_layout.xml
具有多种视图类型,其中一种由 another_recyclerview_layout.xml
表示。当后者存在于 recyclerview_layout.xml
并且 TextInputEditText
填充了一些其他项目时,整个布局具有奇怪的滚动行为,当用户点击 TextInputEditText
之一时。这就像它试图捕捉到焦点 android:focusable="true"
并且用户无法再从该视图滚动离开。 (见下面的gif)
已经尝试过的解决方案
- 将
android:focusableInTouchMode="true"
和nestedScrollView
设置为recyclerview_layout.xml
的直接子级,正如您在android:descendantFocusability="blocksDescendants"
中已经看到的那样。还尝试将这些属性添加到所有其他容器中(哭) - 将
anotherRecyclerView
设置为TextInputEditText
的父级。此解决方案对我不起作用,因为我需要SoftKeyboard
才能完全正常运行。 - 收听
2.0.4
事件并在键盘隐藏后立即清除焦点。此解决方案引发了另外两个问题:
图书馆
约束布局:1.2.0
RecyclerView:1.2.1
材料:"AllData.data": 1,"AllData.data.Brand": { $ifNull: [ "$AllData.data.Brand","$AllData.name" ] }
帮助!
我的想法不多了,非常感谢任何帮助。谢谢!
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)