- 1 无SplashActivity,主要是 切换 theme
- 2 有SplashActivity,单独的Activity,用来显示Splash theme,然后finish()
效果图
代码
https://github.com/dzetAndroid/LearnSplashScreen
layer 图层
opacity 不透明度
opaque 不透明
可以使用mipmap文件夹下的图片,但是android studio没提示
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"
android:opacity="opaque">
<item android:drawable="@color/colorPrimary" />
<item>
<bitmap
android:gravity="center"
android:src="@mipmap/ic_launcher"
/>
</item>
</layer-list>
<resources>
<style name="SplashTheme" parent="AppTheme">
<item name="android:windowBackground">@drawable/splash</item>
</style>
</resources>
<activity android:name=".activities.MainActivity"
android:theme="@style/SplashTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
// Make sure this is before calling super.onCreate
setTheme(R.style.AppTheme);
super.onCreate(savedInstanceState);
}
}
效果图
代码
https://github.com/cstew/Splash
public class SplashActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent intent = new Intent(this, MainActivity.class);
startActivity(intent);
finish();
}
}
https://android.jlelse.eu/launch-screen-in-android-the-right-way-aca7e8c31f52 https://stackoverflow.com/questions/5486789/how-do-i-make-a-splash-screen/15832037#15832037
https://www.bignerdranch.com/blog/splash-screens-the-right-way/
https://www.youtube.com/watch?time_continue=160&v=E5Xu2iNHRkk https://github.com/dzetAndroid/androidVideo(该视频已存储至个人github,欢迎下载,观看)
https://android.jlelse.eu/which-splash-screen-approaches-is-better-4de3128988fd
这篇,进行了讨论,但是个人未发现,无SplashActivity版的,
切换Activity出现Splash theme的现象
YouTube官方Android教程也是无SplashActivity版
end