0

请了解 ia 使用约束布局。视图受到适当的约束。

在布局编辑器预览中,按钮和文本视图都是可见的。当我运行起来时,文本视图是可见的,但按钮是不可见的。

请参阅随附的布局代码和屏幕截图。

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

    <data>

    </data>

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


        <TextView
            android:id="@+id/text_welcome_instructions"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginTop="68dp"
            android:fontFamily="@font/roboto"
            android:gravity="center"
            android:text="@string/welcome_text"
            android:textSize="20sp"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

        <TextView
            android:id="@+id/shoe_text"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="64dp"
            android:fontFamily="@font/roboto_mono"
            android:text="@string/store_text"
            android:textSize="20sp"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintHorizontal_bias="0.498"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/text_welcome_instructions" />

        <Button
            android:id="@+id/instructions_button"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="264dp"
            android:background="@color/colorPrimary"
            android:text="@string/welcome_button"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintHorizontal_bias="0.497"
            app:layout_constraintStart_toStartOf="parent" />
    </androidx.constraintlayout.widget.ConstraintLayout>
</layout>

提前致谢。在此处输入图像描述

在此处输入图像描述

4

1 回答 1

0

问题似乎是保证金底部。我改为使用 Margin Top。

于 2021-01-04T16:50:52.060 回答