Android启动页,解决白屏问题

本文介绍了如何在Android中创建一个自定义的欢迎页背景,并通过设置主题来消除启动时的白屏问题。首先,在drawable中创建一个`welcome_bg_shape.xml`文件,使用layer-list结合shape实现背景和logo的布局。接着,将这个背景设置在style的`SplashTheme`中,确保全屏显示并禁用状态栏背景绘制。最后,在清单文件中应用该主题,从而实现完美的启动体验。
摘要由CSDN通过智能技术生成

首先在drawable中创建一个欢迎页welcome_bg_shape.xml

logo_welcome是启动页要放入的logo或者是一张图片也行,位置大家可以自己调

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <shape android:shape="rectangle">
            <solid android:color="@android:color/white" />
        </shape>
    </item>
    <item
        android:drawable="@drawable/logo_welcome"
        android:gravity="center" />

</layer-list>

        然后在复制代码到style中

<style name="SplashTheme" parent="Theme.AppCompat.NoActionBar">
        <item name="android:windowFullscreen">true</item>
        <item name="windowNoTitle">true</item>
        <item name="android:windowDrawsSystemBarBackgrounds">false</item>
        <item name="android:windowBackground">@drawable/welcome_bg_shape</item>
    </style>

        清单文件中配置theme,然后就完美解决白屏问题

 android:theme="@style/SplashTheme"

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值