加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Java > 正文

java – 此视图不受约束

发布时间:2020-12-15 07:36:19 所属栏目:Java 来源:网络整理
导读:我收到以下错误,我使用 Android工作室2.2预览3.我搜索谷歌但找不到任何资源. 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
我收到以下错误,我使用 Android工作室2.2预览3.我搜索谷歌但找不到任何资源.

Error: This view is not constrained,it only has design time positions,so it will jump to (0,0) unless you add constraints

enter image description here

<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中使用此非常有用的快捷方式:

右键单击widget-in-question>约束布局>推断约束:

enter image description here

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

更新

对于Android Studio v3及更高版本,这是不正确的.根据@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.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读