【问题标题】:Android Studio 3 - Constraint layout editor is not workingAndroid Studio 3 - 约束布局编辑器不工作
【发布时间】:2022-02-01 18:02:02
【问题描述】:

我最近安装了 android studio 3,但约束布局显示一个灰色窗口..我尝试了所有方法,但无法解决问题

提前感谢您提供的任何帮助:

XML 代码:

<?xml version="1.0" encoding="utf-8"?> 
<android.support.constraint.ConstraintLayout 
    xmlns:android="schemas.android.com/apk/res/android"; 
    xmlns:app="schemas.android.com/apk/res-auto"; 
    xmlns:tools="schemas.android.com/tools"; 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context="com.example.chihaoui.myapplication.MainActivi‌​ty"> 
</android.support.constraint.ConstraintLayout>

【问题讨论】:

  • 向我们展示 xml 代码
  • schemas.android.com/apk/res/android" xmlns:app="schemas.android.com/apk/res-auto " xmlns:tools="schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.example.chihaoui.myapplication.MainActivity">
  • 您是否尝试运行该应用程序?运行了吗?
  • 该应用在我的手机上无法运行,但我没有尝试模拟器
  • “没有工作” - 为什么?试试模拟器。我怀疑如果没有错误并且应用程序运行正常,那么问题与设计编辑器有关

标签: android android-constraintlayout


【解决方案1】:

我只是帮助完成了这个项目并赚到了

example

【讨论】:

  • 这太奇怪了,但是 Build -> Make project,让布局编辑器工作了。
【解决方案2】:

我遇到了类似的问题。我的情况是通过在 app/build.gradle 上添加以下几行来解决的:

implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation('com.android.support:appcompat-v7:28.0.0') {
    force = true
}

注意force = true 部分。

【讨论】:

【解决方案3】:

在 build.gradle 中,只需更改:

androidx.constraintlayout:constraintlayout:2.1.3

androidx.constraintlayout:constraintlayout:2.0.4

【讨论】:

  • 这对我有用,似乎 2.1.3 被编译的 31 SDK 破坏了。
【解决方案4】:

你同步你的项目了吗,如果你没有同步项目,我在 gradle 文件中看到黄色消息它不会工作

【讨论】:

  • 你能把你的设计编辑器 api 版本改成更小的版本,然后告诉我是修复问题吗
  • 有趣的是没有错误但是当我运行应用程序时会出现一个弹出窗口“不幸的是我的应用程序已停止”
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2021-10-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-08-03
  • 1970-01-01
相关资源
最近更新 更多