Android ScrollView,在软键盘上的操作栏下

Android ScrollView, under Action Bar on Softkeyboard

我已经阅读了几个关于这个问题的讨论,它与清单文件的 android:windowSoftInputMode="stateHidden|adjustResize"(以及 adjustPan)有关,当试图获取 LinearLayout 的 ScrollView 以调整键盘时已显示。

我的布局在包含 10 个 LinearLayout 部分(TextView/EditText 视图)的 ScrollView 内部有一个 LinearLayout。我已经尝试了我读过的每一种组合,无论如何,当通过单击顶部的 EditText 打开键盘时,将调整(平移)视图,使顶部字段位于操作栏后面。我可以滚动到页面底部,但无法到达顶部 EditText - 我只能滚动到第二个。我可以尝试向下拉,然后我可以开始看到顶部的 EditText,但无法显示它,除非我关闭键盘(显然我无法编辑文本)。

<ScrollView
    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"
    tools:context="com.example.myproject.FirstActivity"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/scrollView"
    tools:showIn="@layout/activity_work"
    android:layout_gravity="center_horizontal">

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

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

        <TextView
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:textAppearance="?android:attr/textAppearanceSmall"
            android:text="x1"
            android:layout_weight="50"/>

        <EditText
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:inputType="numberDecimal"
            android:ems="10"
            android:id="@+id/work_one"
            android:hint="0"
            android:gravity="right"
            android:selectAllOnFocus="true"
            android:textAlignment="gravity"
            android:layout_weight="50" />
    </LinearLayout>
    .
    . (9 more of these)
    .
  </LinearLayout>
</ScrollView>

更新:

所以我尝试了:android:windowSoftInputMode="adjustResize" 和/或 android:windowSoftInputMode="adjustPan" 并且软键盘移动了操作栏下方的顶部字段。

想法?

试试 android:windowSoftInputMode="adjustResize" 或 android:windowSoftInputMode="adjustPan"

来自doc

"adjustResize"

activity 的主 window 总是调整大小以便为屏幕上的软键盘腾出空间。

"adjustPan"

activity 的主 window 未调整大小以为软键盘腾出空间。相反,window 的内容会自动平移,以便当前焦点永远不会被键盘遮挡,用户始终可以看到他们正在输入的内容。这通常不如调整大小可取,因为用户可能需要关闭软键盘才能找到 window.

的遮挡部分并与之交互

我从this Stack Overflow answer

复制了答案