android 实现windowBackground打造闪屏页

WindowBackground打造闪屏页

在创建app的时候Android会立即显示一个backgroundwindow,然后再去创建app进程。这就会产生刚开始打开app的时候出现白屏现象。这篇文章就是为了解决这个白屏现象,如下几步轻松实现闪屏页。

  • 1、新建SplashTheme style
  • 2、在你的app起始页设置style风格
  • 3、设置页面跳转

新建SplashTheme style


 <style name="SplashTheme" parent="AppTheme">
        <item name="android:windowIsTranslucent">false</item>
        <item name="android:background">@mipmap/we</item>
        <item name="android:windowFullscreen">true</item>
    </style>

在你的app起始页设置style风格

<activity
   android:name=".ui.WelcomeActivity"
   android:theme="@style/SplashTheme"
   android:configChanges="orientation|screenSize">
    <intent-filter>
        <actionandroid:name="android.intent.action.MAIN"/>

        <categoryandroid:name="android.intent.category.LAUNCHER"/>
    </intent-filter>
</activity>

设置页面跳转

public class WelcomeActivity extends FragmentActivity {
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        getWindow().setFlags(
                WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);

         /*采用handler创建子线程实现页面跳转*/
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                Intent intent =new Intent(WelcomeActivity.this,LoginActivity.class);
                startActivity(intent);
                WelcomeActivity.this.finish();
            }
        },1000);

    }



}

注意一点的是设置该welcomeActivity的style后只能结束这个activity

详细代码。具体请参考GitHub(https://github.com/zct1115/MyLoginApplication)

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值