关于AndroidAPP启动时发生白屏问题的解决

别废话了,直接上代码:
1.manifest.xml中设置主题:

        <activity
            android:name="com.zack.ownerclient.SplashActivtiy"
            android:screenOrientation="portrait"
            android:theme="@style/SplashTheme">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.DEFAULT"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>

2.styles中准备该主题:

   <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
        <item name="android:windowDrawsSystemBarBackgrounds">false</item><!--解决华为虚拟键盘遮住问题-->
    </style>

    <style name="SplashTheme" parent="AppTheme">
        <!-- 解决启动白屏的问题 -->
        <item name="android:windowBackground">@drawable/theme_splash</item>
        <item name="android:windowFullscreen">true</item>
    </style>

3.准备好这个drawable:theme_splash.xml

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <!-- 背景颜色 -->
    <item android:drawable="@drawable/img_start_bg" />
    <item >
        <bitmap
            android:gravity="center"
            android:id="@+id/bitmap_splash"
            android:src="@drawable/img_start_logo">
        </bitmap>
    </item>
</layer-list>
具体效果.PNG
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 175,173评论 25 709
  • 在网上搜索了许多关于app启动白屏的文章大致分为两类 第一种是在style的app的theme 里设置 true ...
    licue阅读 11,055评论 0 0
  • afinalAfinal是一个android的ioc,orm框架 https://github.com/yangf...
    passiontim阅读 15,663评论 2 45
  • 对暴力说”NO“ 2017-01-17 三三 仙女三三 关注微信公众号:仙女三三。温暖故事陪你度过漫长岁月 壹 前...
    仙女三三阅读 3,188评论 0 1
  • 文/小而不才 怎么办,刚离开家就开始想家了,那六七日假期怎的一眨眼就成了过去时呢?想家,心里淡淡的酸,不知妈妈在家...
    小而不才阅读 2,372评论 2 4