为什么android studio显示“约束布局中缺少约束"的错误? [英] why android studio show error of "Missing constraints in constraintlayout"?

查看:127
本文介绍了为什么android studio显示“约束布局中缺少约束"的错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

图片

这个视图没有约束,它只有设计时的位置,所以它会跳到(0,0),除非你添加约束

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

布局编辑器允许您将小部件放置在画布上的任何位置,并使用设计时属性(例如 layout_editor_absolute X)记录当前位置.这些属性不会在运行时应用,因此如果您将布局推送到设备,小部件可能会出现在与编辑器中显示的位置不同的位置.要解决此问题,请通过从边缘连接处拖动来确保小部件具有水平和垂直约束

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

推荐答案

解决这个问题很简单.只需单击小部件(例如按钮或文本框等),然后单击推断约束"按钮.您可以在附加图片或此 Youtube 链接中看到:https://www.youtube.com/watch?v=uOur51u5Nk0

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

这篇关于为什么android studio显示“约束布局中缺少约束"的错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆