android - 为什么 RecyclerView 项目在键盘出现时损坏?
问题描述
我有以下布局结构:
NestedScrollView
ConstrainstsLayout
SearchView
RecyclerView
RecyclerView
当我点击 时SearchView
,键盘出现并且底部的项目RecyclerView
变大。不能一起查看项目RecyclerView
。他们只一一展示,因为他们的高度,在展示键盘后变得更大。那么,如何解决问题呢?这是布局。
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<data>
<variable
name="viewModel"
type="tech.nplus.yaptk.ui.payment.PaymentViewModel" />
</data>
<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="match_parent">
<android.support.v7.widget.SearchView
android:id="@+id/searchView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
app:iconifiedByDefault="false"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:queryHint="@string/find_service"
/>
<android.support.v7.widget.RecyclerView
android:id="@+id/fast_payment_rv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:layout_marginTop="10dp"
android:orientation="horizontal"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/searchView" />
<android.support.v7.widget.RecyclerView
android:id="@+id/service_list_parent_rv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="vertical"
app:items="@{viewModel.items}"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/fast_payment_rv"
/>
</android.support.constraint.ConstraintLayout>
</android.support.v4.widget.NestedScrollView>
这是3个屏幕。1 显示键盘出现之前,2 显示之后(注意元素消失),3 显示元素如何变大。
PS我把android:windowSoftInputMode="adjustPan"
,否则,我的BottomNavigationView
出现在键盘上方。
解决方案
推荐阅读
- javascript - AngularJs + webpack - 无法读取未定义的属性“可导航”
- java - 在设置的最小值和最大值之间设置编辑文本输入
- javascript - 数据库中某个半径内的位置的API
- r - 地图功能中的波浪号运算符
- javascript - 调用console.log 中的函数没有在firefox 控制台中输出任何内容?
- file - 在python中将base64字符串写入文件不起作用
- xpages - Xpages - 使用旧值刷新文档
- c# - 如何从文本框中获取日期并将其用于 SELECT 语句
- ios - 如何在“AWSIoT”iOS SDK 中订阅多个主题?
- sql - 使用存储过程更新数据库中的现有值