0
我在res/values/styles.xml
修改application theme
:的Android启动屏幕的bug
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="android:windowBackground">@drawable/splash_screen</item>
</style>
创建文件res/drawable/splash_screen.xml
:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<bitmap
android:gravity="center"
android:src="@mipmap/background"/>
</item>
</layer-list>
这里第一错误去。根据我使用教程,这个文件应该有这样的代码:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:drawable="@color/gray"/>
<item>
<bitmap
android:gravity="center"
android:src="@mipmap/background"/>
</item>
</layer-list>
但是有了这个,我正在编制过程中始终得到错误:
res/drawable/splash_screen.xml:5:23-34 : No resource found that matches the given name (at 'drawable' with value '@color/gray').
:app:processDebugResources FAILED
用我这个文件的“版”,它至少通过编译和安装顺利进行。 那么,我如何设置背景?
二,最重要的bug。 如果BG图像不覆盖整个屏幕,然后推出我看到黑色的背景,当应用程序已经启动,我看到:
应用程序的可见部分的形状我用于启动屏幕的背景图像。如果我将它更换为更大的图像(2000px +),那么一切看起来都不错,但我敢打赌,将巨大的bg图像放在那里并不是正确的解决方案。 那么,为什么这个黑色的“覆盖”出现在我的应用程序用户界面上?
您是否向styles.xml或colors.xml添加了“灰色”颜色? – VicVu