android 使布局在软键盘打开时可滚动,但不向上移动

标签 android android-layout scrollable android-keypad

这是我的屏幕,键盘后面隐藏着一个按钮。

我想要完全像这样,但可以滚动。 -

keyboard open with one button hidden behind

每当键盘打开时,我想让它看起来与图像中的一样。但是,改为使其可滚动,以便用户可以滚动查看屏幕的底部(包括按钮),即使键盘打开时也是如此。

我试过了-

android:windowSoftInputMode="adjustResize"

但是,每当键盘打开时,这会将底部向上移动。

如下图所示 -

我不想要这个 -(打开键盘时,向上移动创建帐户按钮)

enter image description here

CREATE ACCOUNT button must be visible after scrolling.

这是布局 -

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"

    android:layout_width="match_parent"
    android:layout_height="match_parent"

    android:id="@+id/root_layout"
    android:fillViewport="true"

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

        android:weightSum="10"

        >
        <LinearLayout  android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="9"
            android:orientation="vertical"
            android:gravity="center_vertical|center_horizontal"
            android:paddingLeft="@dimen/activity_horizontal_margin"
            android:paddingRight="@dimen/activity_horizontal_margin"
            android:paddingTop="@dimen/activity_vertical_margin"
            android:paddingBottom="@dimen/activity_vertical_margin">

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


                <EditText
                    android:id="@+id/et_username_or_email"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:hint="@string/et_hint_username_or_email"
                    android:inputType="textEmailAddress"
                    android:singleLine="true"
                    />
                <EditText
                    android:id="@+id/et_pswd"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:hint="@string/et_hint_password"
                    android:password="true"
                    android:singleLine="true"
                    />

                <Button
                    android:id="@+id/btn_sign_in"
                    android:layout_marginTop="10dp"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="@string/btn_sign_in"
                    android:background="@color/lighter_orange"
                    android:textColor="@android:color/white"/>

                <TextView
                    android:layout_marginTop="10dp"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="@string/or"
                    android:gravity="center_horizontal"
                    android:textColor="@android:color/black"/>


                <Button
                    android:id="@+id/btn_take_a_peek"
                    android:layout_marginTop="10dp"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="@string/btn_take_a_peek"
                    android:textColor="@android:color/white"
                    android:background="@color/button_gray"/>

                <TextView
                    android:layout_marginTop="15dp"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="@string/forgot_password"
                    android:gravity="center_horizontal"
                    android:textColor="@color/text_gray"/>
            </LinearLayout>
        </LinearLayout>
        <LinearLayout  android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:orientation="vertical">


            <Button
                android:id="@+id/btn_create_account"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:text="@string/btn_create_account"
                android:background="@color/button_very_light_orange"
                android:textColor="@android:color/white"/>


        </LinearLayout>
    </LinearLayout>
</ScrollView>

请帮我解决这个问题。

最佳答案

将此输入模式添加到您的 list 文件中。

android:windowSoftInputMode="stateHidden|adjustResize"

关于android 使布局在软键盘打开时可滚动,但不向上移动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32095820/

相关文章:

android - 一次性读取Firebase云( Dart/flutter )

android - 将 yahoo messenger 与 android 应用程序集成

android - ListView 布局背景颜色在滚动时闪烁在图像加载时消失?

css - 调整浏览器大小时如何将每个元素固定在同一位置?

java - 如何使我的 jframe 可滚动而不删除文本

javascript - Jquery/JavaScript OnClick 事件未在移动设备上触发

Android:如何通过xml制作一个看起来像光环的Circle

android - android 中的 View 寻呼机内的 Webview

Android layout_weight 不工作

android - 如何使 listview 和 GridLayout 可滚动