cefsharp 启动白屏处理,启动页白屏及黑屏解决

一.白屏及黑屏产生的原因:

当Activity启动的时候不能马上加载layout。而黑屏或者白屏是AppTheme的默认样式,代码如下:

@color/background_material_light

具体颜色值为:#fffafafa

于是,当layout还没加载完成的时候就会显示相应的主题颜色(黑/白屏)。

二.解决方案:

1.像微信那样,把启动页的窗口背景设为透明。这样,当点击app图标时,因为背景是透明的,所以看不到

任何东西,等layout完全加载好了就可以看到真正的界面了。

a.先设置style:

@android:color/transparent

true

b.在启动activity加入该Theme:

android:theme="@style/SplashTheme.Translucent">

c.千万别忘了在真正的layout添加非透明的背景色,不然界面显示时是透明的:

xmlns:android="http://schemas.android.com/apk/res/android"

xmlns:tools="http://schemas.android.com/tools"

xmlns:app="http://schemas.android.com/apk/res-auto"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:background="@color/white">

......

2.把启动页的主题背景换成图片。当点击app图标时,在layout加载完毕之前都是显示这张背景图片。

当layout加载完毕之后,背景图片才消失,同时显示真正的界面。

a.先设置style:

@drawable/welcome

false

b.在启动activity加入该Theme:

android:theme="@style/SplashTheme.NotTranslucent">

c.千万别忘了在真正的layout添加非透明的背景色,不然界面显示时依然能看到欢迎页那张图片:

xmlns:android="http://schemas.android.com/apk/res/android"

xmlns:tools="http://schemas.android.com/tools"

xmlns:app="http://schemas.android.com/apk/res-auto"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:background="@color/white">

......

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值