启动activity时,有个一闪而过界面

原文点击这里

进入应用时,由于应用的启动Activity都会有默认的theme,所以会跳一下原始界面,才启动我们定义的theme。

修改这个问题的方法,就是给应用启动的Activity设置一个空的theme。如下面的例子:

联系人启动时的Activity为PeopleActivity ,我们就在manifest文件中设置PeopleActivity 的theme为一个空的theme

        <activity android:name=".activities.PeopleActivity"

            android:label="@string/people"

            android:theme="@style/GnEmptyTheme"

            android:uiOptions="splitActionBarWhenNarrow"

            android:clearTaskOnLaunch="true"

            android:launchMode="singleTask"

            android:windowSoftInputMode="adjustPan"

            android:configChanges="orientation"

         >

GnEmptyTheme 就是一个空的theme,里面什么内容页没有,在styles.xml中如下定义:

    <style name="GnEmptyTheme">

    </style>

 

要实现白色主题、黑色主题或者透明主题,就在此Activity的onCreate方法中,使用setTheme设置对应主题即可。

注意setTheme要在super.onCreate(savedInstanceState)之前;

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值