ConstraintLayout之Infer Constraints(推断约束)

在使用 ConstraintLayout 的时候,发现一个异常:

This view is not constrained vertically: at runtime it will jump to the left unless you add a vertical constraint less… (Ctrl+F1)
The layout editor allows you to place widgets anywhere on the canvas, and it records the current position with designtime attributes (such as layout_editor_absoluteX.) These attributes are not applied at runtime, 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.

我仔细检查了约束条件,都是没有问题的,但是显示我缺少约束条件,编译后会将所有的控件堆在左上角,我选择了无视异常,但是异常没有无视我,编译后的效果类似于FarmeLayout没有添加位置约束一样的效果,后来查找百度,发现了解决方案:

1.切换xml到design试图下
2.选中ConstraintLayout右键选择Constraint Layout中的Infer Constraints
引用块内容

但是我将AndroidStudio的视图打开以后,仔细检查了,却没有发现上图的提示:
这里写图片描述

最后我仔细检查了一遍,终于让我找到了:
这里写图片描述

解决问题!

参考:

http://blog.csdn.net/u010296640/article/details/72922165

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值