gpt4 book ai didi

java - 软键盘: Adjust_Resize pushing content offscreen

转载 作者:行者123 更新时间:2023-12-01 18:44:05 24 4
gpt4 key购买 nike

我正在构建一个类似消息传递的应用程序,但我遇到了键盘推送内容错误的问题。

我想要的是内容向上推的高度与键盘的高度一样,并且我能够自由地向上滚动以查看之前的所有消息。就像大多数消息应用程序一样。

这是我的布局。我将布局添加到 ScrollView 内的布局。

<?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"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/open_messsages_constraint"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".OpenMessages">


<ScrollView
android:id="@+id/messages_scroll2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toTopOf="@id/linearLayout">


<LinearLayout
android:id="@+id/allMessage"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical"
app:layout_constraintTop_toTopOf="parent">

</LinearLayout>


</ScrollView>


<LinearLayout
android:id="@+id/linearLayout"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="#ffffff"
android:backgroundTint="#ffffff"
app:layout_constraintBottom_toBottomOf="parent">

<EditText
android:id="@+id/messageInput"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_gravity="center"
android:layout_marginLeft="20dp"
android:layout_weight="4"
android:background="@drawable/rounded_corner"
android:backgroundTint="#f1f1f1"
android:paddingLeft="20dp"
android:textColorLink="#000000" />


<com.google.android.material.button.MaterialButton
android:id="@+id/sendMessageButton"
android:layout_width="50dp"
android:layout_height="30dp"
android:layout_gravity="center"
android:backgroundTint="#ffffff"
android:gravity="center"
android:stateListAnimator="@null"
app:iconTint="#000000">

</com.google.android.material.button.MaterialButton>
</LinearLayout>


</androidx.constraintlayout.widget.ConstraintLayout>

这是点击键盘之前的情况: Before I select the keyboard.这里是之后。我可以向下滚动以查看下面的消息,但我无法向上滚动超过这张图片,所以我错过了一条消息。 After I click the keyboard.

最佳答案

这对我有用:

android:windowSoftInputMode="adjustResize"

并设置 Recyclerview 底部填充的填充。

padding:20

关于java - 软键盘: Adjust_Resize pushing content offscreen,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59871197/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com