始终将按钮放在布局底部



我在RelativeLayout的底部有一个按钮,但在页面上有editText,当这些文本处于活动状态时,键盘会弹出,按钮不会停留在底部,而是会移动到键盘上方。这个按钮是用来发送一个填写好的表单的,所以当它被激活时,我不能让按钮在键盘上方移动。

这是现在的布局

<?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"

为了避免您的视图根据键盘时刻进行调整。

将此行添加到Manifest文件中的活动标记中。

尝试将根布局转换为滚动视图和相对布局作为直接子

最新更新