【问题标题】:Resizing of Layout with Recycler View when the soft keyboard appears出现软键盘时使用 Recycler View 调整布局大小
【发布时间】:2020-04-14 09:50:40
【问题描述】:

我有一个布局,其中包含 Recycler 视图、工具栏和布局底部的 EditText。我想在软键盘出现时调整回收器视图的大小。工具栏应保持在顶部,edittext 应向上移动键盘。仅应调整回收站视图的大小。

布局代码如下

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    android:orientation="vertical"
    android:background="#ffffff">
    <androidx.appcompat.widget.Toolbar
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="#fff"
        android:elevation="4dp"
        app:title="Toolbar" />

    <androidx.recyclerview.widget.RecyclerView
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="#ffffff"
        android:gravity="center"
        android:orientation="horizontal"
        android:padding="8dp">
        <EditText
            android:layout_width="0dp"
            android:layout_height="45dp"
            android:layout_gravity="center_vertical"
            android:layout_weight="1"
            android:backgroundTint="#757575"
            android:textCursorDrawable="@drawable/cursor_color"
            android:textSize="16sp" />
    </LinearLayout>
</LinearLayout>

我在全屏模式下使用窗口。目前的情况是出现软键盘时整个布局向上推,工具栏不可见,只有回收器视图的一部分可见。

谢谢!

【问题讨论】:

    标签: java android android-studio android-recyclerview android-softkeyboard


    【解决方案1】:

    android:windowSoftInputMode="adjustResize" 添加到 manifest.xml 上的活动标签中

    【讨论】:

    • 没有得到预期的结果,整个布局被向上推。
    猜你喜欢
    • 2011-10-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-11-04
    • 2011-07-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多