视图不受约束。它只有设计时间位置,因此它会在运行时跳转到(0,0) 这些属性不会在运行时应用,因此如果您在设备上推送布局,则窗口小部件可能显示在与编辑器中显示的位置不同的位置。
您需要为视图提供垂直和水平约束,因此在运行时,它将具有相对于屏幕的位置。如果您不这样做,您的视图将没有垂直/水平位置,并且如果屏幕将从其位置跳到开始。
你可以这样做,例如:
<TextView
android:id="@+id/textView8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="text"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
此外,您可以查看官方documentation了解更多信息。