【发布时间】:2018-09-27 00:37:46
【问题描述】:
我在这里一步一步关注this tutorial,它在我的 API 21 模拟器上运行良好,但在我的 27 上,它在应用加载时立即崩溃:
java.lang.RuntimeException: 无法启动活动 ComponentInfo{com.myapp.myapp/com.myapp.myapp.ui.SplashScreenActivity}: android.content.res.Resources$NotFoundException: Drawable com.myapp.myapp:drawable /splash_screen_background 资源 ID #0x7f0700a9
我的 drawable/splash_screen_background 文件是这个:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape>
<gradient
android:type="radial"
android:gradientRadius="100%p"
android:startColor="@color/primaryColor"
android:endColor="@color/primaryDarkColor"/>
</shape>
</item>
<item>
<bitmap
android:gravity="center"
android:src="@drawable/ic_home_white_24dp"/>
</item>
</layer-list>
我尝试使用app:srcCompat,将drawable直接传递给item,消除bitmap,但问题仍然存在。我看到有人说要改用android:drawable=,但他们说这会在
This answer 显示了一些非常复杂的额外配置,包括gradle 选项,我不确定这会如何影响我的应用程序,它会改变矢量图形的性能吗?
在适用于多个 API 的 Android 上处理 layer-list 的正确方法是什么?
【问题讨论】:
-
想知道你在哪里应用这个
layer-listsplash_screen_background,你在那里使用app:srcCompat吗?即app:srcCompat="@drawable/splash_screen_background"? -
我将其作为主题应用,如链接教程所示
-
我也有同样的问题。 @mFeinstein 你有没有解决过这个问题?
-
不,我没有:/
-
你有想过这个吗?我突然遇到了同样的问题。
标签: android android-resources android-theme