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

根据提示信息
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
为其添加推断约束即可。


网友评论