Android 始终将按钮放在布局底部

Android 始终将按钮放在布局底部,android,Android,我有一个按钮在相对位置的底部,但在页面上有编辑文本,当这些文本处于活动状态时,键盘弹出,按钮不在底部,而是移动到键盘上方。此按钮用于发送已填完的表单,因此当按钮被激活时,我不能让按钮在键盘上方移动 这就是现在的布局 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http

我有一个按钮在相对位置的底部,但在页面上有编辑文本,当这些文本处于活动状态时,键盘弹出,按钮不在底部,而是移动到键盘上方。此按钮用于发送已填完的表单,因此当按钮被激活时,我不能让按钮在键盘上方移动

这就是现在的布局

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/lightGray"
    android:orientation="vertical">

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

        <androidx.constraintlayout.widget.ConstraintLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">

            <TextView
                android:id="@+id/ind_survey_title"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:text="asdfasdfds group"
                android:textColor="@color/mediumBlue"
                android:textSize="20sp"
                app:layout_constrainedWidth="true"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintTop_toTopOf="parent"
                app:layout_constraintWidth_percent="0.75" />

            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:gravity="center_vertical"
                android:orientation="horizontal"
                app:layout_constrainedWidth="true"
                app:layout_constraintRight_toRightOf="parent"
                app:layout_constraintTop_toTopOf="parent"
                app:layout_constraintWidth_percent="0.25">

                <ImageView
                    android:id="@+id/ind_survey_anonymous_icon"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:scaleX="0.8"
                    android:scaleY="0.8"
                    android:src="@drawable/ic_x" />

                <TextView
                    android:id="@+id/ind_survey_anonymous"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/anonymous"
                    android:textColor="@color/red"
                    android:textSize="14sp" />

            </LinearLayout>

        </androidx.constraintlayout.widget.ConstraintLayout>

        <TextView
            android:id="@+id/ind_survey_desc"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="@dimen/D5dp"
            android:paddingStart="@dimen/D20dp"
            android:paddingEnd="@dimen/D5dp"
            android:text=""
            android:textColor="@android:color/black"
            android:textSize="14sp" />

        <View
            android:layout_width="match_parent"
            android:layout_height="1dp"
            android:background="@color/mediumGray" />

        <androidx.recyclerview.widget.RecyclerView
            android:id="@+id/reclycer_view_survey_questions"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@color/lightGray" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:gravity="end"
        android:orientation="vertical">

        <Button
            android:id="@+id/sendbtn"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/login_button"
            android:minHeight="0dp"
            android:text="@string/send_survey"
            android:textAllCaps="false"
            android:textColor="@android:color/white"
            android:textSize="14sp" />
    </LinearLayout>
</RelativeLayout>

当键盘处于活动状态时,如何确保按钮不移动?

利用此功能:

  android:windowSoftInputMode="adjustNothing"
以避免视图根据键盘时刻进行调整


在清单文件中的活动标记中添加这一行。

尝试将根布局转换为scrollview和相对布局,作为直接子级。

您是否在清单中添加了android:WindowsofInputMode=“adjustPan | stateHidden”?@IntelliJAmiya否,这是在一个片段中,这做了什么?它的根活动在清单部分