1.首页主题
<style name="SplashTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- 欢迎页背景引用刚才写好的 -->
<item name="android:windowBackground">@drawable/splash</item>
<item name="android:windowFullscreen">true</item>
<!-- <item name="android:windowIsTranslucent">true</item> --> <!-- 透明背景不要了 -->
</style>
2.首页onCreate
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val intent = Intent(this,MainActivity::class.java)
startActivity(intent)
this.finish()
}
3.首页的主题背景splash.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!-- 背景颜色 -->
<item android:drawable="@color/white" />
<item>
<!-- 图片 -->
<bitmap
android:gravity="center"
android:src="@drawable/mylogo" />
</item>
</layer-list>
网友评论