拖放组件在android studio的预览中不可见

拖放组件在android studio的预览中不可见,android,android-layout,android-studio,Android,Android Layout,Android Studio,我是android开发的初学者。我已经创建了一个android项目。但在预览部分,我无法看到组件。但当我在emulator上运行相同的应用程序时,组件是可见的,我可以看到组件。我错过了一些场景?下面给出了XML <?xml version="1.0" encoding="utf-8"?> <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/a

我是android开发的初学者。我已经创建了一个android项目。但在预览部分,我无法看到组件。但当我在emulator上运行相同的应用程序时,组件是可见的,我可以看到组件。我错过了一些场景?下面给出了XML

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

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


</android.support.constraint.ConstraintLayout>

也许听起来是个奇怪的答案,但自我测试了一下

  • 将XML文件(可能是activity_x.XML)布局的根标记
    android.support.constraint.ConstraintLayout
    更改为
    LinearLayout
    ,然后预览将再次开始工作(就像我的例子一样)。[如果不是,则执行强制刷新(R)]

  • 然后切换回旧的布局,我的意思是:将XML文件(可能是activity_x.XML)布局的根标记
    LinearLayout
    更改为
    android.support.constraint.ConstraintLayout
    。并强制刷新


    • 这似乎是Android Studio中的一个bug。当它出现在我面前时,我通过在app
      build.gradle
      (更改版本代码)中做一个小的更改来修复它,执行一次gradle同步,然后更改回并再次同步


      之后,设计视图再次工作

      我也遇到了这个问题,只选择了另一个“主题”原因就解决了它 默认主题appTheme不显示添加的项目。 如果选择Transulcent,则任何项目都将可见;-)

      干杯
      Oliwan

      Android研究中可能存在一些奇怪的索引/缓存问题在“文件”选项的左上角单击“无效缓存/重新启动”,然后单击“无效并重新启动”