Android启动界面优化技巧-Splash Screens的正确方式
生活随笔
收集整理的这篇文章主要介绍了
Android启动界面优化技巧-Splash Screens的正确方式
小编觉得挺不错的,现在分享给大家,帮大家做个参考.
备注:这里是开发跨平台App时,适配Android启动屏幕,主要为了防止白屏。玩Android开源App 往往我们在开发Android的时候会出现白屏等等,主要原因就是启动时需要加载的资源过多,从而影响了Android启动,Google建议的启动方式:www.google.com/design/spec…,如果能够翻越围墙的同学可以看一下? 好了我们下面就直接说明了
1. 在res/drawable下创建一个bg_splash.xml文件,并写下下面的内容
其中@drawable/splas是一张图片,来自drawable文件夹下 其中@color/gray是灰色,来自colors.xml文件
xml version="1.0" encoding="utf-8" <layer-list xmlns:android="http://schemas.android.com/apk/res/android"><item android:drawable="@color/gray" /><item><bitmapandroid:src="@drawable/splash" /></item> </layer-list> 复制代码2. 在styles.xml文件下创建SplashTheme的主题,引入bg_splash
<resources><!-- Base application theme. --><style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"><!-- Customize your theme here. --></style><style name="SplashTheme" parent="Theme.AppCompat.NoActionBar"><item name="android:windowBackground">@drawable/bg_splash</item></style> </resources> 复制代码3.在你的启动界面中引入SplashTheme,如下
<activityandroid:name=".SplashActivity"android:theme="@style/SplashTheme">android:noHistory="true"><intent-filter><action android:name="android.intent.action.MAIN" /><category android:name="android.intent.category.LAUNCHER" /></intent-filter></activity> 复制代码最终就完成了 在SplashActivity中,你可以setContentView加载View,也可以不用 参考资源:https://www.bignerdranch.com/blog/splash-screens-the-right-way/
《新程序员》:云原生和全面数字化实践50位技术专家共同创作,文字、视频、音频交互阅读总结
以上是生活随笔为你收集整理的Android启动界面优化技巧-Splash Screens的正确方式的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: Shell编程常用命令
- 下一篇: Android 高级进阶之overdra