1. 程式人生 > >This view is not constrained. It only has designtime positions, so it will jump to (0,0) at runtime

This view is not constrained. It only has designtime positions, so it will jump to (0,0) at runtime

使用 ConstraintLayout 遇到的問題

This view is not constrained. It only has designtime positions, so it will jump to (0,0) at runtime

ConstraintLayout是Android Studio 2.2中主要的新增功能之一,我們在使用時遇到了如上所述的問題,通過Design面板拖拽的元件報錯。
如圖所示,使用ImageView報錯

解決方案:
在AndroidStudio升級到3.0 及以上版本時,按如下方法解決。
開啟Design面板,在工具欄找到“Infer Constraints”按鈕,點選即可。
上圖示紅所示