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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章