这种观点不受约束

新手上路,请多包涵

我收到以下错误,我正在使用 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 许可协议

阅读 800
1 个回答

快速 解决此问题,请在 Android Studio 中使用这个非常有用的快捷方式:

右键单击有问题的小部件 > 约束布局 > 推断约束:

在此处输入图像描述

此后,您可以按照此处所述调整约束: https ://stackoverflow.com/a/37960888/5556250

更新

这对于 Android Studio v3 及更高版本是不正确的。根据 @purpleladydragons 的评论

“约束布局”不在下拉菜单中。使用设计预览上方工具栏菜单中的魔术棒图标;有“推断约束”按钮。

原文由 Jay Souper 发布,翻译遵循 CC BY-SA 3.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题