键盘打开时调整布局大小

时间:2018-10-26 22:37:09

标签: java android xml android-studio

我想在打开软键盘时调整活动布局的大小。 我尝试将其放在清单中:

android:windowSoftInputMode="adjustResize"

但是它不起作用。这是我的xml布局:

<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"
    android:fitsSystemWindows="true"
    tools:context=".ui.SettingsActivity">

    <!-- BODY -->
    <ScrollView
        android:id="@+id/scrollViewBody"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <!-- my list -->

        </LinearLayout>
    </ScrollView>

    <!-- TOOLBAR -->
    <include layout="@layout/toolbar" />

键盘打开时布局不会调整大小... 请帮助我

1 个答案:

答案 0 :(得分:0)

documentation

  

“调整大小”   活动的主窗口始终会调整大小以使其   屏幕上的软键盘的空间。

     

“ adjustPan”   活动的主要内容   窗口没有调整大小以为软键盘腾出空间。而是   窗口的内容会自动平移,以便当前   键盘永远不会遮挡焦点,用户始终可以看到   他们正在打字。通常不如调整大小理想,   因为用户可能需要关闭软键盘才能到达和   与窗口的模糊部分进行交互。

我相信您想要的是 adjustPan

相关问题