android - 文本编辑器键盘与 recyclerview 列表重叠

标签 android keyboard android-recyclerview

布局在 View 底部有一个回收 View 和一个文本编辑器。当我单击编辑器时,键盘弹出并与 recycerview 重叠。我希望在调出键盘时调整 recyclerview 的大小。在我的 list 文件中,我有:

   <activity android:name=".CommentActivity" 
                           android:label="yourtime"
                           android:windowSoftInputMode="adjustResize">
                          </activity>

我的布局是这样的:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
    android:id="@+id/rv"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" />
<LinearLayout
    android:orientation="horizontal"
    android:minWidth="25px"
    android:minHeight="25px"
    android:id="@+id/linearLayout1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:weightSum="100"
    android:layout_alignParentBottom="true">
    <EditText
        android:inputType="textMultiLine"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="85"
        android:id="@+id/commenteditor"
        android:hint="Write a comment" />
    <ImageButton
        android:src="@drawable/arrow"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="15"
        android:id="@+id/send"
        android:background="#ffff" />
</LinearLayout>

如何在键盘出现时使列表向上滚动或调整大小?我曾尝试将 recyclerview 封装在 scrollview 中,但这没有用。

这是它的样子:

enter image description here

我希望它看起来像这样:

enter image description here

我该怎么办?

最佳答案

在你的

<activity android:name=".CommentActivity" 
                       android:label="yourtime"
                       android:windowSoftInputMode="adjustResize|adjustPan">
                      </activity>

你不能拥有多个

adjustResize|adjustPan

此结果未定义。

在你的情况下,你想要的是

<activity android:name=".CommentActivity" 
                       android:label="yourtime"
                       android:windowSoftInputMode="adjustResize"/>

您可以在这里阅读更多相关信息:

activity-element 在涵盖 android:windowSoftInputMode 的部分

您还应该调整布局,使回收站 View 位于编辑文本容器上方。

<android.support.v7.widget.RecyclerView
     android:id="@+id/rv"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:layout_above="@+id/linearLayout1"/>

关于android - 文本编辑器键盘与 recyclerview 列表重叠,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36777860/

相关文章:

java - 将套接字从 Android 发送到 Python 服务器

python - 在python中轮询键盘(检测按键)

C SDL 键盘事件 SDL_KEYUP 按键按下时触发

c# - 区分键盘的真实和虚拟按键

java - recyclerview的notifyItemInserted插入到错误的位置

android - 如何访问隐藏的 RecyclerView 项目?

android - RecyclerView里面的Grid,哪一列是左边还是右边

java - 以编程方式设置 ImageView 的宽度和高度?

android - Android 平台上的浏览器插件查询(Froyo 2.2.1 版本)

android - 如何使用字节数组上传图像