关于app打开白屏问题

在style.xml里面写样式,如下

<style name="SplashTheme" parent="AppTheme">
        <!--不在意变形的话直接用图片就是-->
        <item name="android:windowBackground">@mipmap/first</item>
        <!--全屏-->
        <item name="android:windowFullscreen">true</item>
        <item name="android:windowContentOverlay">@null</item>
        <!--去除状态栏-->
        <item name="android:windowTranslucentStatus">true</item>
        <item name="android:windowTranslucentNavigation">true</item>
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>
    </style>
<activity
            android:name="com.eluton.first.FirstActivity"
            android:launchMode="singleTask"
            android:theme="@style/SplashTheme">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
                <!--<data-->
                <!--android:host="com.eluton.medclass"-->
                <!--android:scheme="cundong" />-->
            </intent-filter>
        </activity>

然后如上图,修改AndroidManifest.xml,在第一个页面那里加入android:theme="@style/SplashTheme"就是。但上面也说了,直接用图片的话因为各种手机手机屏幕比例的问题,图片会变形。 <itemname="android:windowBackground">@mipmap/first</item>,Background嘛,就是说drawable什么的也能放进去,这样的话我们在drawable文件夹自定义一个layer_list,就叫layer_splash.xml吧,然后把@mipmap/first换成<itemname="android:windowBackground">@drawable/layer_splash</item>

<?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="#ffffff" />
        </shape>
    </item>
    <!--android:bottom根据情况来定,ic_launcher一般换成自己app的logo图片,运行一遍就知道怎么修改了-->
    <item
        android:bottom="20dp"
        android:drawable="@mipmap/ic_launcher"
        android:gravity="center|bottom" />
</layer-list>

猜你喜欢

转载自blog.csdn.net/qq_36961698/article/details/120441035