美文网首页
关于app打开白屏问题

关于app打开白屏问题

作者: 名字不想带英文 | 来源:发表于2019-11-07 11:22 被阅读0次

    在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"就是。但上面也说了,直接用图片的话因为各种手机手机屏幕比例的问题,图片会变形。 <item name="android:windowBackground">@mipmap/first</item>,Background嘛,就是说drawable什么的也能放进去,这样的话我们在drawable文件夹自定义一个layer_list,就叫layer_splash.xml吧,然后把@mipmap/first换成<item name="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>
    

    相关文章

      网友评论

          本文标题:关于app打开白屏问题

          本文链接:https://www.haomeiwen.com/subject/dqsmbctx.html