android - windowSoftInputMode 问题

android - windowSoftInputMode issue

如何在软输入打开时显示红色区域的相对布局?我尝试了 adjustPan 和 adjustResize 输入模式,但没有发生。有什么想法吗?


首先,将 android:windowSoftInputMode="adjustResize" 添加到 manifest.xml 的 activity。

然后创建如下布局。

  • 作为家长,使用RelativeLayout
  • 放入 2 个子视图(ScrollView 和 Bottom View)
  • 底视图aligned to bottom
  • ScrollView 位于底视图 above

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <ScrollView
        android:layout_above="@+id/bottomView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        //scrollable content
    </ScrollView>

    <RelativeLayout
        android:id="@+id/bottomView"
        android:layout_alignParentBottom="true"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        //your bottom content
    </RelativeLayout >
</RelativeLayout>