【Android】ConstraintLayout布局中使用控件提示This view is not constrained, it only has designtime positions,...

问题背景

在ConstraintLayout布局内使用控件时遇到This view is not constrained, it only has designtime positions, so it will jump to (0,0) unless you add constraints提示,具体信息如下图:

tips.png

根据提示信息 This view is not constrained, it only has designtime positions, so it will jump to (0,0) unless you add constraints(译:这个视图不受约束,它只有设计时位置,所以它会跳转到(0,0),除非你添加约束)我们可以得知这是在提示我们为该控件添加约束。


解决方法

点击Design切换到布局预览模式,在Component Tree内鼠标右键ConstraintLayout->Constraint Layout->Infer constraints为其添加推断约束即可。

operation.png
result.png
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容