如何在android中保持键盘顶部的视图

MAR*_*RSH 0 android

这是我的 xml:

<androidx.constraintlayout.widget.ConstraintLayout 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:fillViewport="true">

    <ScrollView
        android:id="@+id/scroll_view"
        android:layout_width="0dp"
        android:layout_height="0dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintHorizontal_bias="1.0"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="1.0">

        <androidx.constraintlayout.widget.ConstraintLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="center"
            android:background="@color/white"
            android:paddingLeft="@dimen/cl_12"
            android:paddingTop="@dimen/cl_48"
            android:paddingRight="@dimen/cl_12"
            android:paddingBottom="@dimen/cl_28">

            <ImageView
                android:id="@+id/imageView"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@drawable/fingerprint_id"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent" />

            <TextView
                android:id="@+id/tv_title"
                style="@style/Typeface.Body.Bold.TextDarkGrey"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="@dimen/padding_8"
                android:lineSpacingExtra="4sp"
                android:text="Enter your password"
                app:layout_constraintTop_toBottomOf="@+id/imageView"
                tools:ignore="MissingConstraints" />

            <TextView
                android:id="@+id/tv_fingerprint_description"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="@dimen/cl_16"
                android:lineSpacingExtra="8sp"
                android:text="Enter your Tesco password to activate fingerprint ID"
                app:layout_constraintTop_toBottomOf="@+id/tv_title"
                tools:ignore="MissingConstraints" />

            <EditText
                android:id="@+id/et_input_text"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="@dimen/cl_20"
                android:ems="10"
                android:focusable="true"
                android:focusableInTouchMode="true"
                android:hint="Password"
                android:inputType="textPassword"
                app:layout_constraintTop_toBottomOf="@+id/tv_fingerprint_description" />

            <TextView
                android:id="@+id/tv_close"
                style="@style/Typeface.Body.TescoBlue"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="@dimen/cl_24"
                android:layout_marginRight="@dimen/padding_8"
                android:lineSpacingExtra="8sp"
                android:padding="@dimen/padding_8"
                android:text="Cancel"
                app:layout_constraintEnd_toStartOf="@+id/tv_submit"
                app:layout_constraintTop_toBottomOf="@+id/et_input_text" />

            <TextView
                android:id="@+id/tv_submit"
                style="@style/Typeface.Body.TescoBlue"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="@dimen/cl_24"
                android:lineSpacingExtra="8sp"
                android:padding="@dimen/padding_8"
                android:text="Submit"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/et_input_text"
                tools:ignore="MissingConstraints" />


        </androidx.constraintlayout.widget.ConstraintLayout>
    </ScrollView>

</androidx.constraintlayout.widget.ConstraintLayout>
Run Code Online (Sandbox Code Playgroud)

这是我在课堂上写的代码

et_input_text.setOnFocusChangeListener(object  : View.OnFocusChangeListener{
            override fun onFocusChange(v: View?, hasFocus: Boolean) {
                if(hasFocus)
                scroll_view.scrollTo(0,scroll_view.bottom)
            }

        })

in manifest file, I have added 



<activity
            android:name=".features.common.customview.FingerPrintWithPasswordDialogActivity"
            android:theme="@style/PaddedScreenDialogTheme"
            android:windowSoftInputMode="adjustPan"
            android:screenOrientation="portrait" />
Run Code Online (Sandbox Code Playgroud)

我正在尝试将提交和取消按钮设置在键盘顶部,但它隐藏在键盘内部,请向我建议如何实现此目的。 在此输入图像描述

请在这个屏幕中看到“提交”并且运河被隐藏,我想滚动整个底部,以便它应该显示“取消”和“提交”按钮。

Kis*_*rya 5

尝试通过删除

 android:windowSoftInputMode="adjustPan"
Run Code Online (Sandbox Code Playgroud)