遇到的情况:

app启动时进入启动页时出现白屏页,然后大概一秒之后就出现了背景图片。

原因:app启动时加载的是windows背景,之后再加载布局文件的,所以开始的黑屏/白屏就是windows的背景颜色,因此我们只要在启动页设置windows背景颜色就好了,那么在哪里设置呢?  就是theme里面。

解决办法:参考:【Android Drawable 那些不为人知的高效用法

Android 启动APP时黑屏白屏的三个解决方案

首先看之前的布局文件xml写法

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitXY"
android:background="@drawable/bg_app_welcome_1"/>
<LinearLayout
android:id="@+id/v_prepare_tips"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_alignParentBottom="true"
android:gravity="center"
android:orientation="horizontal"
android:visibility="gone">
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center"
android:textColor="#007ed2"
android:text="首次安装正在准备数据"/>
<ProgressBar
android:layout_width="20dp"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"/>
</LinearLayout> </RelativeLayout>

=========================================================

优化之后的:

<!-- 只是将根元素的背景去掉了 -->
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:id="@+id/v_prepare_tips"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_alignParentBottom="true"
android:gravity="center"
android:orientation="horizontal"
android:visibility="gone">
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center"
android:textColor="#007ed2"
android:text="首次安装正在准备数据"/>
<ProgressBar
android:layout_width="20dp"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"/>
</LinearLayout>
</RelativeLayout>

设置style.xml

    <style  name="AppStartingBg"  parent="@android:style/Theme.Holo.Light.NoActionBar" >
<item name="android:windowBackground">@drawable/bg_appstarting</item>
</style>
bg_appstarting.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item >
<bitmap android:src="@drawable/bg_app_welcome_1" android:gravity="fill" />
</item>
</layer-list>

再在manifest.xml文件中添加该ancivity的theme

<activity
android:name="com.client.activity.AppStartingActivity"
android:icon="@drawable/ic_logo_2"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:theme="@style/AppStartingBg" >
<intent-filter>
<action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

大功告成!

android开发 解决启动页空白或黑屏问题的更多相关文章

  1. CentOS7安装vncserver(启动失败及连接黑屏解决办法)

    CentOS7安装vncserver(启动失败及连接黑屏解决办法) 转载weixin_34167043 最后发布于2017-11-09 15:11:00 阅读数 42  收藏 展开 AutoSAR入门 ...

  2. Android实例-解决启动黑屏问题(XE8+小米2)

    结果: 1.在启动时马上出现图片界面,但在出现程序界面前会有黑屏,大约有0.2秒左右. 实现: 1.建立2个文件:loading.png和styles.xml: ①其中loading.png是启动时替 ...

  3. Android APP应用启动页白屏(StartingWindow)优化

    版权声明:本文为HaiyuKing原创文章,转载请注明出处! 前言 StartingWindow 的处理方式: 使用系统默认的 StartingWindow :用户点了应用图标启动应用,马上弹出系统默 ...

  4. Android Activity切换(跳转)时出现黑屏的解决方法

    在两个Activity跳转时,由于第二个Activity在启动时加载了较多数据,就会在启动之前出现一个短暂的黑屏时间,解决这个问题比较简单的处理方法是将第二个Activity的主题设置成透明的,这样在 ...

  5. iOS开发 关于启动页和停留时间的设置

    引言: 在开发一款商业App时,我们大都会为我们的App设置一个启动页. 苹果官方对于iOS启动页的设计说明: 为了增强应用程序启动时的用户体验,您应该提供一个启动图像.启动图像与应用程序的首屏幕看起 ...

  6. Android -- 使用主题配置文件,去掉程序启动界面的短暂黑屏

    关于黑屏 默认的情况下,程序启动时,会有一个黑屏的时期,原因是,首个activity会加载一些数据,比如初始化列表数据等. 去除步骤 1./res/values/styles.xml 在 Theme ...

  7. egret 解决游戏loading前的黑屏

    一.问题 egret游戏loading界面的制作可以参考这个,我就不多赘述啦,步骤也比较详细<Egret制作Loading页面及分步加载资源教程>. 后面我发现即便加上loading,在游 ...

  8. Android 解决启动页白屏或者黑屏的问题

    欢迎页启动的线程由于请求和处理的数据量过大而,导致欢迎页在出现之前界面上会有一个短暂的白色闪屏停留,当然白色闪屏的停留是因为 application 的主题样式android:theme=@style ...

  9. android 启动时的短暂黑屏解决

    http://blog.csdn.net/lonely_fireworks/article/details/22291835 http://www.cnblogs.com/henanjing/arch ...

随机推荐

  1. 蘑菇街iOS客户端应用源码

    蘑菇街iOS客户端应用源码 随着蘑菇街由导购向电商转型,蘑菇街自己的IM也应运而生,IM起初只是用于商家和买家之间沟通的工具.后面我们问自己,既然已经有了用于客服的IM,为什么不自己做一个IM,用于公 ...

  2. 支持在安卓中UI(View)的刷新功能

     这是一款可以支持在安卓中UI(View)的刷新功能,Android中对View的更新有很多种方式,使用时要区分不同的应用场合.我感觉最要紧的是分清:多线程和双缓冲的使用情况.   现在可以尝试理解下 ...

  3. nodejs前端自动化构建

    http://99jty.com/?p=1257 http://www.jankerli.com/?p=1628 http://www.cnblogs.com/zhepama/archive/2013 ...

  4. SDUST 作业10 Problem I 液晶显示

    Description 你的朋友刚买了一台新电脑,他以前用过的最强大的计算工具是一台袖珍计算器.现在,看着自己的新电脑,他有点失望,因为他更喜欢计算器上的LC显示器.所以,你决定写一个LC显示风格的程 ...

  5. Could not get JDBC Connection; nested exception is org.apache.commons.dbcp.SQLNestedException:

    七月 17, 2014 4:56:01 下午 org.apache.catalina.core.StandardWrapperValve invoke SEVERE: Servlet.service( ...

  6. AeroSpike 资料

    文档总览:http://www.aerospike.com/docs/ JAVA AeroSpike知识总览:http://www.aerospike.com/docs/client/java/sta ...

  7. php __clone需要注意的问题

      当一个对象的属性是另外一个对象时,当有一个对象复制该对象时,当复制到这个属性(一个对象)时,只复制这个属性(对象)的引用,而不复制引用的对象. class Account{ public $bal ...

  8. 使用junit进行Spring测试

    这几天在做SpringMVC的项目,现在总结一下在测试的时候碰到的一些问题. 以前做项目,是在较新的MyEclipse(2013)上面进行Maven开发,pom.xml 文件是直接复制的,做测试的时候 ...

  9. linuxok6410的I2C驱动分析---用户态驱动

    3  i2c-dev 3.1 概述 之前在介绍I2C子系统时,提到过使用i2c-dev.c文件在应用程序中实现我们的I2C从设备驱动.不过,它实现的是一个虚拟,临时的i2c_client,随着设备文件 ...

  10. String类详解,StringBuffer

    先说一下String类的equals()方法. 下面我们先看一段代码: 这段代码输出的结果为: ture true -------------- false 咋看之下貌似Object类比较特别,那么我 ...