Android Activity切换(跳转)时出现黑屏的解决方法 分享
时间:2022-10-25 15:41:07
在两个Activity跳转时,由于第二个Activity在启动时加载了较多数据,就会在启动之前出现一个短暂的黑屏时间,解决这个问题比较简单的处理方法是将第二个Activity的主题设置成透明的,这样在启动第二个Activity时的黑屏就变成了显示第一个Activity界面。这个分两步完成:
第一步:xxx/res/values/styles.xml中加入自定义Activity的Theme,如下所示:
[html] <style name="Transparent" parent="android:Theme.Light">
<!--将Activity的Theme设置成透明-->
<item name="android:windowIsTranslucent">true</item>
</style>
<style name="Transparent" parent="android:Theme.Light">
<!--将Activity的Theme设置成透明-->
<item name="android:windowIsTranslucent">true</item>
</style>第二步:在AndroidManifest.xml中将第二个Activity的"android:theme"属性设置成刚才自定义的主题样式。如下所示:
[html] <activity
android:name="com.yutao.customer.CustomerActivity"
android:label="@string/app_name"
android:theme="@style/Transparent">
<activity
android:name="com.yutao.customer.CustomerActivity"
android:label="@string/app_name"
android:theme="@style/Transparent"> 到此应该就不会出现那个讨厌的黑屏了。
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Spring boot整合log4j2过程解析
![](https://img.aspxhome.com/file/2023/7/60107_0s.png)
Spring Cloud Hystrix 服务降级限流策略详解
![](https://img.aspxhome.com/file/2023/4/67104_0s.png)
Spring5学习之基础知识总结
![](https://img.aspxhome.com/file/2023/0/104000_0s.png)
在C#中根据HardwareID获取驱动程序信息的实现代码
详解Android中的Context抽象类
![](https://img.aspxhome.com/file/2023/0/93300_0s.png)
Java使用JDBC连接Oracle_MSSQL实例代码
基于ChatGPT+SpringBoot实现智能聊天AI机器人接口并上线至服务器的方法
![](https://img.aspxhome.com/file/2023/5/68015_0s.png)
Java 调用Restful API接口的几种方式(HTTPS)
Android 自定义View实现芝麻分曲线图效果
![](https://img.aspxhome.com/file/2023/3/138873_0s.png)
C#生成验证码图片的方法
SpringBoot 如何实现异步编程
SpringBoot项目创建使用+配置文件+日志文件详解
![](https://img.aspxhome.com/file/2023/9/59509_0s.jpg)
C# 设计模式系列教程-简单工厂模式
![](https://img.aspxhome.com/file/2023/3/75623_0s.png)
C#读写操作app.config中的数据应用介绍
c#.net 常用函数和方法集
解决IDEA2020 创建maven项目没有src/main/java目录和webapp目录问题
![](https://img.aspxhome.com/file/2023/0/81260_0s.png)
Java String类的性质与比较
![](https://img.aspxhome.com/file/2023/2/91732_0s.jpg)
C#窗体间通讯的几种常用处理方法总结
![](https://img.aspxhome.com/file/2023/1/94661_0s.jpg)