【Android】This view is not constrained. It only has designtime positions, so it will jump to (0,0) at runtime unless you add the constraints

現象

This view is not constrained. It only has designtime positions, so it will jump to (0,0) at runtime unless you add the constraints

というエラーで怒られ、「Design」で指定した場所にパーツが配置されない

原因

コード上、パーツをどこに置くかの指定ができていない状態になっているらしい

解決策

xmlファイルで、該当パーツに以下のコードを入れてあげると、「Design」で指定した箇所に反映されるようになった

app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"

コメント

タイトルとURLをコピーしました