Android閃屏頁狀態欄的出現將閃屏畫面向下擠壓

1 Splash頁面常用於啓動的頁面改善用戶體驗防止白屏頁面影響體驗

2 常見做法

創建splash頁面  

SplashActivity

設置theme

在styles.xml文件中設置頁面的主題

代碼如下:

<style name="SplashTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="android:windowBackground">@mipmap/icon_splash</item>
        <item name="android:windowDrawsSystemBarBackgrounds">true</item>
        <item name="android:windowContentOverlay">@null</item>
        <item name="android:windowFullscreen">false</item>
        <item name="android:windowNoTitle">true</item>
</style>

其中windowBackground設置的是啓動的畫面對應的圖片

設置Androidmanifest的啓動頁爲splash頁面

         <!--開屏頁面-->
<activity
        android:theme="@style/SplashTheme"
        android:name=".splash.SplashActivity" >
        <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
 </activity>

注意:

<item name="android:windowDrawsSystemBarBackgrounds">true</item>

這個屬性如果設置爲false的話,畫面會有跳動,整個畫面會向下移動一個狀態欄高度的位置。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章