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编程常用命令
- 下一篇: Qt编写安防视频监控系统4-删除视频