このビューは制約されていません。設計時の位置しかないため、(0,0)にジャンプします...



This View Is Not Constrained



This view is not constrained. It only has designtime positions, so it will jump to (0,0) at runtime unless you add the constraints less... (Ctrl+F1) Inspection info:The layout editor allows you to place widgets anywhere on the canvas, and it records the current position with designtime attributes (such as layout_editor_absoluteX). These attributes are not applied at runtime, so if you push your layout on a device, the widgets may appear in a different location than shown in the editor. To fix this, make sure a widget has both horizontal and vertical constraints by dragging from the edge connections.

この状況は、ConstraintLayoutを使用するレイアウトにあります。これはエラーではなく、単なる警告です。無視して実行できますが、ビューは制約レイアウトによって提供されるパラメーターを使用しないため、このビューは(0,0にジャンプします。 )実行時の位置。したがって、Viewを使用するときは、次のパラメータを設定する必要があります。

app:layout_constraintStart_toStartOf
app:layout_constraintEnd_toEndOf
app:layout_constraintTop_toTopOf
app:layout_constraintBottom_toBottomOf



もちろん、すべての設定が必要なわけではありません。それらのいくつかを設定するだけで、その場所を特定できます。
セットとして:

app:layout_constraintStart_toStartOf='parent' app:layout_constraintEnd_toEndOf='parent' app:layout_constraintTop_toTopOf='parent'

これは、コントロールが上部にあることを意味します。つまり、コントロールの左側がConstraintLayoutの左側に「固定」され、右側がConstraintLayoutの右側に「固定」され、上部が「固定」されます。 ConstraintLayoutの上部に「固定」されます。これにより、コントロールの位置が決まります。



または:

app:layout_constraintStart_toStartOf='parent' app:layout_constraintTop_toTopOf='parent'

これにより、その場所も決まります。