【发布时间】:2020-01-15 18:40:05
【问题描述】:
我有这个splash_screen.xml:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:drawable="@color/colorPrimary"/>
<item
android:gravity="center"
android:src="@mipmap/ic_launcher"/>
</layer-list>
然后我想将它作为<item> 添加到styles.xml:
<style name="SplashTheme" parent="Theme.AppCompat.NoActionBar">
<item name="android:windowBackground">@drawable/splash_screen</item>
</style>
但这会引发:
Caused by: android.content.res.Resources$NotFoundException: File res/drawable/splash_screen.xml from drawable resource ID #0x7f070099
当我尝试时:
<item name="android:windowBackground">@color/colorPrimary</item>
我的代码运行良好,并且在 colorPrimary 中显示了一个屏幕。
我该如何解决?
我尝试重建、清理、重新启动 Android Studio 以及 SO 上的每一篇文章。没有任何帮助。
编辑
splash_screen.xml肯定在可绘制文件夹中。
Android Studio 正在建议该文件。
我的可绘制文件夹:
【问题讨论】:
-
能否分享一下android studio资源中文件树的截图。
-
您已将启动画面 xml 添加到您的可绘制文件夹中?
-
@PrajwalW 是的,到我的可绘制文件夹。
-
建议一个文件并不意味着什么。如果您需要帮助,请从 Android Studio 中发布文件树的屏幕截图,res 目录
-
@mac229 我现在添加了
标签: android file exception splash-screen filenotfoundexception