`
whotodo
  • 浏览: 168628 次
文章分类
社区版块
存档分类
最新评论

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

 
阅读更多

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

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

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

<activityandroid: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中如下定义:

<stylename="GnEmptyTheme">

</style>

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

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

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics