Android Studio Android -ScrollView末尾的按钮不可见

l7wslrjt  于 2022-11-30  发布在  Android
关注(0)|答案(1)|浏览(152)

我在ScrollView布局的末尾添加了一个按钮,里面是一个约束布局。两者都在一个相对布局中。但是,滚动时,按钮没有在我的设备上显示。它卡在布局的底部,不能起来。我已经尝试了所有方法。

<?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"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".activities.BachelorDetailActivity"
    android:id="@+id/layout_fragment_studyplan">

        <ScrollView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            android:clipToPadding="false"
            android:fillViewport="true">

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

                <TextView
                    android:id="@+id/h1_studyplan"
                    android:textSize="@dimen/h1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/title_studyplan"
                    app:layout_constraintTop_toTopOf="parent"
                    app:layout_constraintStart_toStartOf="parent"
                    android:textColor="@color/color_primary"
                    android:textStyle="bold"
                    android:textAllCaps="true"
                    android:paddingTop="@dimen/margin_default"
                    android:paddingStart="@dimen/margin_default"/>

                <TextView
                    android:id="@+id/p_studyplan"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    app:layout_constraintTop_toBottomOf="@id/h1_studyplan"
                    app:layout_constraintStart_toStartOf="parent"
                    android:text="@string/list_studyplan"
                    android:paddingBottom="@dimen/margin_huge"
                    android:paddingStart="@dimen/margin_default"
                    android:paddingTop="@dimen/margin_default"
                    android:singleLine="false"
                    android:lineSpacingExtra="@dimen/margin_short"/>

                <Button
                    android:id="@+id/btn_contact_study"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintEnd_toEndOf="parent"
                    app:layout_constraintTop_toBottomOf="@id/p_studyplan"
                    android:layout_width="wrap_content"
                    android:layout_height="@dimen/button"
                    android:layout_marginBottom="500dp"
                    android:text="@string/contact_guide"
                    android:textColor="@color/white"
                    android:backgroundTint="@color/color_primary"/>

            </androidx.constraintlayout.widget.ConstraintLayout>

        </ScrollView>

</RelativeLayout>
txu3uszq

txu3uszq1#

如果您尝试将android:layout_marginBottom="500dp"设定为按钮的下边界,让按钮在屏幕上向上滑动500dp,您也需要指定按钮的下限制式。

app:layout_constraintBottom_toBottomOf="parent"

仅当边距方向存在有效约束时,才应用边距。

相关问题