此视图不受android studio 的限制.即使使用 Infer Constraints 也看不到按钮 [英] This view is not constrained android studio. I can not see the button even if I use Infer Constraints

查看:92
本文介绍了此视图不受android studio 的限制.即使使用 Infer Constraints 也看不到按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

即使使用了推断约束,按钮也不会出现在 xml 中.

Button Doesn't appear in xml even after infer constraints is used.

enter code here
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity"
    tools:layout_editor_absoluteY="25dp">

    <Button
        android:id="@+id/button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Button"
        tools:layout_editor_absoluteX="133dp"
        tools:layout_editor_absoluteY="253dp" />
</android.support.constraint.ConstraintLayout>

推荐答案

您的按钮似乎缺少水平/垂直约束.

It seems your button is missing horizontal/vertical constraints.

尝试像这样更改按钮约束.

Try changing your button constraint like this.

 <Button
        android:id="@+id/button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Button"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        tools:layout_editor_absoluteX="133dp"
        tools:layout_editor_absoluteY="253dp" />

运行您的活动/片段是一个设备/模拟器.即使没有显示按钮,Android Studio 的设计视图上也会出现渲染按钮问题.尝试在编辑器中更改 API 版本.

And run your activity/fragment is a device/emulator. Even if that doesn't show up button, there is issue rendering button over the design view of the Android Studio. Try changing API version in editor.

这篇关于此视图不受android studio 的限制.即使使用 Infer Constraints 也看不到按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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