我试图创建一个聊天布局,所以我有一个循环视图,其中有一个EditText(使用圆角背景)和一个ImageButton来发送消息,但是当软键盘出现时,它覆盖了EditText和ImageButton的一小部分。
我的AndroiManifest
中有android:windowSoftInputMode="adjustPan"
我试过了
- 使用
android:windowSoftInputMode="adjustResize
时,它占用了所有资源,包括我的BottomNavigationView
(我不希望这样) - 将
app:paddingBottomSystemWindowInsets="@{true}"
放在约束布局上
下面是我的布局:
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_support"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="1"
android:transcriptMode="alwaysScroll"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
app:layout_constraintBottom_toTopOf="@id/et_support"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:reverseLayout="true"
tools:itemCount="3"
tools:listitem="@layout/item_support_received" />
<androidx.appcompat.widget.AppCompatEditText
android:id="@+id/et_support"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/btn_support_send"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/rv_support"
/>
<com.google.android.material.button.MaterialButton
android:id="@+id/btn_support_send"
android:layout_width="50dp"
android:layout_height="50dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="@id/et_support"
app:layout_constraintTop_toBottomOf="@id/rv_support" />
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
下面是我的两张图片显示的问题:
3条答案
按热度按时间mm9b1k5b1#
我通过执行以下操作找到了一个变通方案:
1.我在我的机器人清单中返回到
adjustPan
1.在我的片段中,我补充道:
nszi6y052#
在回收视图中添加底部填充“16”。
ruarlubt3#
在我的情况下,我已经实现如下,在此
1.在布局文件中添加滚动视图
1.更改应用主题
和布局文件作为
仅此而已,快乐编码:)