【问题标题】:Android Studio . Design unable to see anything on design安卓工作室。设计看不到设计上的任何东西
【发布时间】:2018-08-17 22:46:01
【问题描述】:

我刚刚在我的新 Windows 10 上安装了 android studio。我之前在 Windows 8 上使用过,它工作正常。我面临的问题非常基本但非常重要。我看不到布局设计组件。请查看图片,它将帮助您更好地理解。

【问题讨论】:

  • 让我猜猜,您使用的是 SDK 28?尝试更改为 SDK 27,看看是否获得预览。
  • 尝试在预览选项中将 sdk 更改为 25
  • 在这里发布你的styles.xml
  • 张贴您的 xml 文件以便更好地理解
  • 你可以参考一次:stackoverflow.com/a/51686210/5870824

标签: android android-layout android-studio


【解决方案1】:

您需要在父视图中设置约束位置

<?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="fill_parent"
    android:layout_height="fill_parent"
    android:id="@+id/ConstraintLayout">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        android:text="hello World"
        />
</android.support.constraint.ConstraintLayout>

【讨论】:

    【解决方案2】:

    在编辑器中点击天蓝色图标,最后会出现强制刷新布局选项。

    点击它。它将刷新布局。

    如果不行

    • 更改设备和主题。

    • 清理并重建项目,然后打开 xml 文件。

    【讨论】:

      【解决方案3】:

      这似乎是AppCompat 最新版本中的错误。

      Gradle 中更改AppCompat 库版本:

      在设计时

      来自

      implementation 'com.android.support:appcompat-v7:28.0.0-rc01' 
      

      收件人

      implementation 'com.android.support:appcompat-v7:27.1.1'
      

      构建时

      AppCompat版本改回:

      implementation 'com.android.support:appcompat-v7:28.0.0-rc01'.
      

      通过这样做,您将可以在设计和构建时使用最新的 sdk 进行预览。 :)

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2015-12-28
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-07-28
        • 2018-12-15
        • 2013-05-11
        相关资源
        最近更新 更多