我收到以下错误,我正在使用 Android Studio 2.2 Preview 3。我搜索了 Google,但找不到任何资源。
Error: This view is not constrained, it only has design time positions, so it will jump to (0,0) unless you add constraints
<TextView
android:layout_width="384dp"
android:layout_height="207dp"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="@string/calc_default_display"
android:id="@+id/textView"
android:background="#ffffff"
android:layout_margin="0dp"
android:gravity="bottom|end"
android:textSize="70sp"
android:nestedScrollingEnabled="false"
android:maxLines="2"
android:maxLength="17"
tools:layout_editor_absoluteX="0dp"
tools:layout_editor_absoluteY="0dp" />
原文由 Isuru 发布,翻译遵循 CC BY-SA 4.0 许可协议
要 快速 解决此问题,请在 Android Studio 中使用这个非常有用的快捷方式:
右键单击有问题的小部件 > 约束布局 > 推断约束:
此后,您可以按照此处所述调整约束: https ://stackoverflow.com/a/37960888/5556250
更新
这对于 Android Studio v3 及更高版本是不正确的。根据 @purpleladydragons 的评论: