javaandroidandroid-layoutandroid-studioandroid-fragments

why android studio show error of "Missing constraints in constraintlayout"?


picture

This view is not constrained, it only has design time positions, so it will jump to (0,0) unless you add constraints

The layout editor allows you to place widgets anywhere on the canvas, and it records the current position with design time attributes (such as layout_editor_absolute X.) These attributes are not applied at run time, 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


Solution

  • It is very simple to solve this problem. Just click on the widget (for example button or textbox, etc.) then click on the "Infer constraints" Button. You can see in the attached picture or this Youtube link: https://www.youtube.com/watch?v=uOur51u5Nk0

    Infer constraints picture