此视图不受约束 [英] This view is not constrained

查看:363
本文介绍了此视图不受约束的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到以下错误,我使用的是Android工作室2.2预览版3.我搜索了Google但找不到任何资源。

I get the following error and I am using Android studio 2.2 Preview 3. I searched Google but couldn't find any resources.

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" />


推荐答案

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

To quickly resolve this, use this very helpful shortcut in Android Studio:

右键单击widget-in-question> Constraint Layout> Infer Constraints:

Right-click widget-in-question > Constraint Layout > Infer Constraints:

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

Thereafter, you can tweak the constraints as described here: https://stackoverflow.com/a/37960888/5556250

更新

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

This is not correct for the Android Studio v3 and up. As per @purpleladydragons's comment:


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

"Constraint Layout" is not in the dropdown menu. Use the magic wand icon in the toolbar menu above the design preview; there is the "Infer Constraints" button.

这篇关于此视图不受约束的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆