一、制作一个启动屏的.9图片
根据需求做拉伸效果(上左拉伸背景,右下拉伸内容),保存到drawable
目录
![](https://img.haomeiwen.com/i9471683/361e334ecb4176e8.png)
二、创建新主题
在res => values => styles.xml
下创建如下主题(如:AppTheme.StartingWindowTheme
)
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@android:color/transparent</item>
<item name="android:itemBackground">@color/backgroundColor</item>
</style>
<!-- 应用启动页(StartingWindow)的theme -->
<style name="AppTheme.StartingWindowTheme" parent="AppTheme">
<!-- 可以设置成纯颜色(设置一个和Activity UI相似的背景) -->
<!--<item name="android:windowBackground">@color/startingwindow_bgcolor</item>-->
<!--也可以设置成一张图片 -->
<item name="android:windowBackground">@drawable/ic_launcher_screen</item>
<item name="android:windowFullscreen">true</item>
</style>
三、在AndroidManifest.xml
使用该主题
在系统启动的第一个activity
中使用该主题
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ak.aigo">
<application
android:name=".app.AiGoApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launchera"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".ui.splash.SplashActivity"
android:theme="@style/AppTheme.StartingWindowTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
网友评论