始终将按钮放在版面底部

问题描述 投票:0回答:1

我把按钮放在RelativeLayout的底部,但在页面上有editTexts,当这些都被激活时,键盘弹出,按钮不会留在底部,而是移动到键盘上方。这个按钮是用来发送已完成填写的表单的,所以当它被激活时,我不能让按钮移动到键盘上方。

这就是现在的布局

<?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
1个回答
1
投票

利用这一点。

  android:windowSoftInputMode="adjustNothing"

为了避免你的视图被调整为每一个键盘的时刻。

在Manifest文件的Activity Tag中添加这一行。


0
投票

试着把根布局变成滚动视图,把相对布局变成直接的子布局。

© www.soinside.com 2019 - 2024. All rights reserved.