简体   繁体   English

为什么我在Android Studio中的布局预览为空?

[英]Why is my layout preview in Android Studio empty?

My issue is similar to this but Android Studio doesn't tell me anything about a rendering issue or compiler/build errors(I was able to build fine). 我的问题与相似,但是Android Studio并没有告诉我有关渲染问题或编译器/构建错误的任何信息(我能够很好地构建)。

Here is what I am seeing(this is a new project) 这是我所看到的(这是一个新项目) 在此处输入图片说明

And the contents of content_main.xml 以及content_main.xml的内容 在此处输入图片说明

After reading on different rendering issue threads, I I've tried rebuilding, cleaning, invalidate caches/restart and even starting a new project to see if the layout preview was working(Still empty) 在阅读了不同的渲染问题线程后,我尝试了重建,清理,使缓存无效/重新启动,甚至开始了一个新项目,以查看布局预览是否正常工作(仍然为空)

I also played around with different sdk versions(20,19) to see if the layout preview was working but all I got was this quirky issue that I don't think would cause the layout preview to not work. 我还尝试了不同版本的sdk(20,19),以查看布局预览是否正常工作,但我所得到的只是这个古怪的问题 ,我认为不会导致布局预览无法正常工作。

Does anyone know what my problem is here? 有人知道我的问题在这里吗? I didn't mess around with my initial Gradle files and remove any support library dependencies. 我没有弄乱我最初的Gradle文件,也没有删除任何支持依赖项。 Another solution I had in mind was reinstalling Android Studio but that's last resort. 我想到的另一个解决方案是重新安装Android Studio,但这是不得已的方法。

Just check your sdk valid version like example. 只需检查您的sdk有效版本(如示例)即可。 在此处输入图片说明

在此处输入图片说明

Try putting your TextView element into an empty FrameLayout: 尝试将TextView元素放入一个空的FrameLayout中:

<FrameLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/my_groups" />

</FrameLayout>

This code above should be put inside your RelativeLayout. 上面的代码应放在您的RelativeLayout中。 Hope it helps. 希望能帮助到你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法在我的Android Studio中查看布局预览 - Not Able to view layout preview in my Android studio 当包含布局到coordinatior视图中时,android Studio布局预览为空 - android Studio layout preview is empty when include layout into the coordinatior view Android Studio布局预览 - Android Studio Layout Preview Android Studio中没有布局预览 - No layout preview in Android Studio 为什么我的 Android Studio (Kotlin) 在 Preview 中显示了 Android 手机的布局,而在 Build App 中没有显示? - Why is my Android Studio (Kotlin) showing the layout of an Android phone in Preview but not in the Build App? 为什么布局设计预览未显示在我的Android Studio上? - Why doesn't the layout design preview get displayed on my Android Studio? Android Studio:为什么嵌入在布局中的选项菜单不会显示在我的模拟器/预览中? - Android Studio: Why won't the options menu embedded on layout show on my emulator/preview? 如何在 Android Studio 布局预览中选择我的主题 - How to choose my Theme in Android Studio layout preview Android Studio 布局预览无法获取我当前的主题 - Android studio layout preview does not get my current theme 我的(特定)布局导致 Android Studio XML 布局预览继续加载而不显示预览 - My (Specific) layout causes Android Studio XML Layout Preview to keep on loading and not displaying the preview
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM