【Android】ConstraintLayout布局中使用控件

2017-08-14  本文已影响5872人  紫豪

问题背景

在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
上一篇 下一篇

猜你喜欢

热点阅读