【Android小知识】
为了解决Android冷启动延迟、白屏等问题,往往会将启动图片设置到styles.xml文件中去,但是直接在style文件中引用图片的话很大可能会造成图片拉伸和变形,所以建议将图片配置到xml中去,最后在style文件中引入xml就可以了,如下代码所示:
style.xml
<style name="SplashActivityThemes" parent="Theme.AppCompat.NoActionBar">
<item name="android:windowBackground">@drawable/bg_splash</item>
<item name="android:windowFullscreen">true</item>
</style>
bg_splash.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<shape>
<solid android:color="#FFFFFF"/>
</shape>
</item>
<item
android:bottom="50dp">
<bitmap
android:gravity="bottom|center_horizontal"
android:src="@mipmap/icon_welcome"/>
</item>
</layer-list>