[英]windowSoftInput hides items in recycleview
Im creating a chat app and so far it looks something like this:我正在创建一个聊天应用程序,到目前为止它看起来像这样:
The moment I start typing it hides the last 2 items and looks like (the edittext hides g,h messages):我开始输入的那一刻,它隐藏了最后两项,看起来像(edittext 隐藏了 g、h 消息):
My XML file looks as follows:我的 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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ChatActivity">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_Messages"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintHeight_percent="0.9"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageButton
android:id="@+id/ib_Send"
style="?android:borderlessButtonStyle"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:adjustViewBounds="true"
android:src="@drawable/ic_location_on_black_24dp"
app:layout_constraintHeight_percent="0.1"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
<EditText
android:id="@+id/et_Message"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:hint="enter message here"
android:backgroundTint="@color/colorLightPurple"
android:inputType="textMultiLine|textPersonName"
app:layout_constraintHeight_percent="0.1"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/ib_Send"
app:layout_constraintStart_toStartOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
and I have added to my manifest android:windowSoftInputMode="adjustPan"
我已经添加到我的清单
android:windowSoftInputMode="adjustPan"
Is there a way that I can make sure that my recycleview will always show the lates messages/ make sure the edittext wont hide?有没有一种方法可以确保我的回收视图始终显示最新消息/确保编辑文本不会隐藏?
Thank you谢谢
Use the combination of relative and linear layout and then use marginBottom inside recyclerview.使用相对和线性布局的组合,然后在recyclerview 中使用marginBottom。 Hope you will find it.
希望你能找到它。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ChatActivity">
<include
android:id="@+id/chat_toolbar"
layout="@layout/app_bar_layout">
</include>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/private_messages_list_of_users"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/chat_toolbar"
android:layout_above="@+id/chat_linear_layout"
android:layout_marginBottom="6dp"
>
</androidx.recyclerview.widget.RecyclerView>
<RelativeLayout
android:id="@+id/chat_linear_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentBottom="true"
android:background="@android:color/background_light"
android:orientation="horizontal"
>
<ImageButton
android:id="@+id/send_files_btn"
android:layout_width="60dp"
android:layout_height="50dp"
android:src="@drawable/ic_attach_file_black_24dp"
android:layout_alignParentStart="true"
android:backgroundTint="@android:color/white"
/>
<EditText
android:id="@+id/input_message"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="type message here..."
android:padding="15dp"
android:maxLines="5"
android:layout_toEndOf="@+id/send_files_btn"
android:layout_toStartOf="@+id/send_message_btn"
/>
<ImageButton
android:id="@+id/send_message_btn"
android:layout_width="60dp"
android:layout_height="wrap_content"
android:src="@drawable/send_message"
android:layout_alignParentEnd="true"
android:backgroundTint="@android:color/white"
/>
</RelativeLayout>
</RelativeLayout>
check out my above example...看看我上面的例子......
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.