猿问

键盘打开时调整布局大小

我想在软键盘打开时调整我的活动布局。我试着把它放在清单中:


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" />

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


慕妹3242003
浏览 132回答 1
1回答

饮歌长啸

从文档"adjustResize"&nbsp;活动的主窗口总是调整大小,为屏幕上的软键盘腾出空间。"adjustPan"&nbsp;活动的主窗口不会调整大小来为软键盘腾出空间。相反,窗口的内容会自动平移,因此当前焦点永远不会被键盘遮挡,用户始终可以看到他们正在键入的内容。这通常不如调整大小理想,因为用户可能需要关闭软键盘才能进入窗口的模糊部分并与之交互。我相信你想要的是adjustPan。
随时随地看视频慕课网APP

相关分类

Java
我要回答