外部应用跳转到 其他activity, 或本应用启动首页面白屏





android启动activity时会有一个带标题栏的白色界面闪过


闪频的原因分析:App启动需要时间,在APP启动完成后才会出现 我们想要跳转到的界面
在启动之前则会显示主题样式的默认背景,一般默认的Theme会带标题栏,背景为白色,如果theme设置为NoTitleBar则会出现纯白色闪频。






1. 设置EmptyTheme 

当我们进入我们自己的android时,会有一个带标题栏的白色页面一闪而过,这主要是在系统启动Activity时,会默认的启动系统本身的原始页面,
也就是原始的theme,然后才启动到我们定义的页面。解决的办法很简单,我们只需要设置一个空的theme就好了。
方法:找到自己程序目录下的AndroidManifest.xml

<activity   ---- 为 application 设置?activity的话用处不大一般都是有theme的  
            android:name="com.example.test.login"  
            android:label="@string/app_name"  
            android:theme="@style/EmptyTheme"  
            android:screenOrientation="landscape" >  
            <intent-filter>  
                <action android:name="android.intent.action.MAIN" />  
                <category android:name="android.intent.category.LAUNCHER" />  
            </intent-filter>  
        </activity>  

在你开始启动的activity下添加一句android:theme="@style/EmptyTheme",
此处给我们设置一个空的原始页面,然后在res文件夹下的values目录下,找到styles.xml,打开添加一句

<style name="EmptyTheme">  
    </style>  




2.  解决方法分析:通过 Theme 和 Style 避免 APP 启动闪屏

为 Theme 设置背景图 
    <style name="AppStartTheme" parent="android:Theme">
        <item name="android:windowBackground">@drawable/splash_bg</item>
        <item name="android:windowNoTitle">true</item>
    </style>



 3. 为 Theme 设置透明属性  -- 效果不好
    <style name="AppStartTheme" parent="android:Theme">
        <item name="android:windowIsTranslucent">true</item>
        <item name="android:windowNoTitle">true</item>
    </style>
    <activity
        android:name="com.sunzn.act.SplashActivity"
        android:label="@string/app_name"
        android:theme="@style/AppStartLoadTranslucent"/>

猜你喜欢

转载自blog.csdn.net/kongbaidepao/article/details/80717383
今日推荐