【问题标题】:Android Studio Design not displaying anythingAndroid Studio Design 不显示任何内容
【发布时间】:2018-06-17 18:35:39
【问题描述】:

编辑:我是stackoverflow的新手,所以它不会让我直接上传..请点击下面的链接 Android Studio EMPTY DESIGN

它在模拟器和我的物理设备中运行良好,但我在设计布局上看不到任何东西.. 我已经尝试了以下通过搜索谷歌获得的解决方案 更新的 SDK 更新了 Android Studio 我也尝试过构建>清理项目

文件>使缓存无效/重新启动 试图将 API 更改为旧版本,如 API 25 和 API 26 ..(当前安装的 API 28).. 仍然没有任何工作可以帮助我.. XML 代码

<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">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello World!"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <ImageView
        android:id="@+id/imageView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:contentDescription="@null"
        app:srcCompat="@drawable/ball_100x100"
        tools:layout_editor_absoluteX="127dp"
        tools:layout_editor_absoluteY="399dp" />

</android.support.constraint.ConstraintLayout>

【问题讨论】:

  • 您可以通过点击右上角的红色图标来检查错误或警告
  • @Yatin 它说渲染问题..无法实例化一个或多个类
  • @SmitShah 大多数情况下,您使用的是来自外部库的自定义视图,设计预览无法处理,但是当您运行应用程序时它会起作用
  • 您可以通过更改 api 级别进行检查并进行锻炼

标签: android android-studio


【解决方案1】:

无论如何,我找到了答案,谢谢你..也许它是 Android Studio 中的一个错误.. 解决方案 转到顶部的设计平面单击主题图标并选择任何 Light.DarkActionBar 例如 Material Light->Material.Light.DarkActionBar..

【讨论】:

    【解决方案2】:

    在您的样式 xml 文件中更改:

    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    

    到这里:

    <style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
    

    为我工作。

    【讨论】:

      猜你喜欢
      • 2023-02-07
      • 1970-01-01
      • 1970-01-01
      • 2019-09-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多