作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在构建一个类似消息传递的应用程序,但我遇到了键盘推送内容错误的问题。
我想要的是内容向上推的高度与键盘的高度一样,并且我能够自由地向上滚动以查看之前的所有消息。就像大多数消息应用程序一样。
这是我的布局。我将布局添加到 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>
这是点击键盘之前的情况: 这里是之后。我可以向下滚动以查看下面的消息,但我无法向上滚动超过这张图片,所以我错过了一条消息。
最佳答案
这对我有用:
android:windowSoftInputMode="adjustResize"
并设置 Recyclerview 底部填充的填充。
padding:20
关于java - 软键盘: Adjust_Resize pushing content offscreen,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59871197/
我正在尝试创建一个内部带有 TextInputLayout 的 BottomSheetDialogFragment。我将此 BottomSheet 设置为 adjustResize 以防止键盘覆盖 T
我正在构建一个类似消息传递的应用程序,但我遇到了键盘推送内容错误的问题。 我想要的是内容向上推的高度与键盘的高度一样,并且我能够自由地向上滚动以查看之前的所有消息。就像大多数消息应用程序一样。 这是我
我是一名优秀的程序员,十分优秀!