app啟動后的白屏問題,默認都是在splash頁面加主題配置,主題配置一個背景來達到用戶點擊app圖示就立馬啟動app的假象,大多情況下,使用背景單一的圖片作為啟動圖,我們在設定背景顏色,就能適配的很不錯了(背景顏色+logo圖片的模式),但是當啟動圖不再單一,而且復雜的圖形時候,適配就成大問題了,下面介紹我的方法:
1 設定splash主題
<style name="MySplashTheme" parent="@android:style/Theme.Holo.NoActionBar">
<item name="android:windowBackground">@drawable/splah_bg</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowBackground">@color/white</item>
<item name="android:windowDrawsSystemBarBackgrounds">false</item>
</style>
2 splash_bg 設定:
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/wecome4"
android:dither="true"
android:filter="true"
android:antialias="true"
android:gravity="fill">
</bitmap>
這里面的gravity = fill是設定圖片拉伸的(可以用.9圖片)
3 splash布局檔案設定:
<ImageView
android:id="@+id/iv_bg"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:background="@drawable/splah_bg" />
注意這里的圖片設定用 backgroup,而不是src,然后背景用上面的drawable檔案,而不是直接使用圖片,不然主題到splash布局切換的時候,圖片會閃動,
注意這里的圖片設定用 backgroup,而不是src,然后背景用上面的drawable檔案,而不是直接使用圖片,不然主題到splash布局切換的時候,圖片會閃動,
注意這里的圖片設定用 backgroup,而不是src,然后背景用上面的drawable檔案,而不是直接使用圖片,不然主題到splash布局切換的時候,圖片會閃動,
上面說的是不能設定背景顏色的,如果啟動圖背景是純色的,比如天貓那種,就一白色加一個logo,那種主題設定就不一樣了,請用下面這種模式
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape>
<solid android:color="#FFFFFF" />
</shape>
</item>
<item >
<bitmap
android:gravity="fill"
android:src="@drawable/wecome4"
android:dither="true"
android:filter="true"
android:antialias="true"
/>
</item>
</layer-list>
好了,如果有用請點贊收藏一下
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/402772.html
標籤:其他
上一篇:同一局域網下安卓真機無線除錯
