Android: 当键盘出现时,ScrollView 中的 EditText 消失了

Android: EditText in ScrollView goes of the screen when kayboard appears

我正在尝试创建登录屏幕。我已经使用 ScrollView 来保存输入字段。我有以下 xml:

<RelativeLayout ... >
    <RelativeLayout
        android:id="@+id/top_menu" ... >
        <ImageButton ... />
        <com.neopixl.pixlui.components.textview.TextView... />
    </RelativeLayout>

    <ScrollView
        android:id="@+id/scroll_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_below="@+id/top_menu"
        android:overScrollMode="always">

        <LinearLayout
            android:id="@+id/login_group"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:gravity="center"
            android:orientation="vertical">

            <com.neopixl.pixlui.components.edittext.EditText
                android:id="@+id/user_name_email"
                android:layout_width="match_parent"
                android:layout_height="@dimen/input_height_size"
                android:layout_marginEnd="20dp"
                android:layout_marginStart="20dp"
                android:background="@drawable/edit_text_strock"
                android:hint="@string/user_Name_Email_EditText"
                android:maxLines="1"
                android:paddingLeft="10dp"
                android:paddingStart="10dp"
                android:textColor="@color/White"
                android:textColorHint="@color/White"
                android:textSize="@dimen/register_input_text_size"
                pixlui:typeface="MuseoSans.otf"/>

            <com.neopixl.pixlui.components.edittext.EditText.... />
            <com.neopixl.pixlui.components.button.Button... />
            <com.neopixl.pixlui.components.textview.TextView... />
            <com.neopixl.pixlui.components.textview.TextView... />
            <com.neopixl.pixlui.components.textview.TextView... />
            <com.neopixl.pixlui.components.button.Button... />
        </LinearLayout>
    </ScrollView>
</RelativeLayout>

您可以看到完整的 xml here。 当我单击 EditText user_name_email 时,它会离开屏幕。

点击前:

点击后:

我已经尝试了 scrollTo(x, y)smootScrollTo(x, y) 但它们没有用。

我该如何解决?

更新:

adjustPan 有效,但我希望它与 adjustResize 一起使用。 可能吗?

在清单文件中使用以下行,对于 activity 您需要更改。

android:windowSoftInputMode="adjustPan"

如下图使用:

<activity
            android:name=".ActivityName"
            android:label="title_for_activity"
            android:windowSoftInputMode="adjustPan" >
        </activity>

希望对您有所帮助。

将此添加到清单文件:

android:windowSoftInputMode="adjustPan"

在目标 activity 标签中。