社区微信群开通啦,扫一扫抢先加入社区官方微信群
社区微信群
//styles.xml 设置主题
<style name="SplashTheme" parent="Theme.AppCompat.NoActionBar">
<item name="android:windowBackground">@drawable/bg_splash</item>
<item name="android:windowFullscreen">true</item>
</style>
//activity使用主题,这时点击app图标,就会显示@drawable/bg_splash图片
<activity android:name=".MainActivity"
android:theme="@style/SplashTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
//使用layer-list添加多个图层,返回LayerDrawable
//注意:bitmap使用的图片大小要小于屏幕大小
<?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="10dp">
<bitmap
android:gravity="bottom"
android:src="@drawable/ic_bg_splash"/>
</item>
</layer-list>
//android:windowDrawsSystemBarBackgrounds属性是API 21以上的,需要放在values-v21文件夹里
<style name="SplashTheme" parent="Theme.AppCompat.NoActionBar">
<item name="android:windowBackground">@drawable/bg_splash</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">false</item>
</style>
如果觉得我的文章对您有用,请随意打赏。你的支持将鼓励我继续创作!