关于闪屏页使用了图片背景内存中不会释放

2021-10-08  本文已影响0人  程序员大耳

一、启动页面

众所周知,APP在启动的时候,会有一小段时间(白屏、黑屏),系统会预读APP的主题,所以有的黑屏,有的白屏。

设置启动页目的:提升用户体验。

1方案(使用Splash页面)

1、建立 Splash 页面(好多人这样叫),并通过设置theme,使用背景颜色或者图片代替空白页面。

2、在res/values/styles 文件中,新建一个theme

<style name="SplashTheme" parent="MyMaterialTheme.Base">

    <item name="android:windowBackground">@drawable/ic_newsplash</item>

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

    <item name="android:windowTranslucentNavigation">false</item>

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

</style>

3、使用图片,放到 drawable文件夹下面(适配这个可要考虑了),而且如果使用了图片,内存中不会释放

4、将theme 设置为 SplashActivity中。

使用了图片,内存中不会释放

// 解决启动页图片内存中不会释放问题

Activity onCreate方法最后一行设置

this.setTheme(R.style.OnePixelActivity);

<style name="OnePixelActivity" parent="MyMaterialTheme">

    <item name="android:windowIsTranslucent">false

</style>

上一篇 下一篇

猜你喜欢

热点阅读