【问题标题】:This view is not constrained android studio此视图不受 android studio 约束
【发布时间】:2019-01-04 04:53:08
【问题描述】:

我是 android studio 的新手,刚刚安装了 3.1.3,当我创建新项目时,没有“hello world!”我的布局中的文本。即使在教程中,当我们创建新项目时,“hello world”文本也会自动出现。然后,我尝试按照此链接中的说明进行操作

This view is not constrained

我尝试使用“推断约束”但它不起作用,我该如何解决这个问题??

【问题讨论】:

  • 与问题分享您的 layout.xml 文件
  • 我将在下面分享我的 .xml 文件
  • 我已经解决了我的错误,谢谢

标签: android android-layout android-studio-3.0


【解决方案1】:

您正在使用约束布局作为父布局,因此当使用约束布局、用户相对、线性或任何其他布局作为父布局时,您必须提供顶部、底部、左侧和右侧视图,或者为这样的视图提供约束布局约束在约束的帮助下视图被约束在父中心的示例

        <Button
        android:id="@+id/button2"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:text="Button"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"/>

【讨论】:

  • 我已经尝试过您的解决方案,但没有出现该按钮。并出现警告,“硬编码字符串“按钮”,应该使用@string资源”。
  • 我得到了我的错误的解决方案,这不是因为 .xml 而是因为 implementation 'com.amdroid. bla bla bla' 在我的应用程序文件中。很抱歉打扰你,但谢谢你
猜你喜欢
  • 1970-01-01
  • 2019-01-29
  • 2021-05-29
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-11-29
  • 2016-10-17
  • 2018-12-21
相关资源
最近更新 更多