android开屏页单张图片设置的收评秒开引起的图片变形问题

通过设置 windowBackground 一张图片的方式可以使app冷启动的时候首屏秒开,避免白屏和黑屏以及点击启动图标延迟的问题,但是只有一张图片的时候就会可能出现这张出现在引导页的图片显示变形。

<style name="LaunchTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <!-- Customize your theme here. -->
        <item name="android:windowFullscreen">true</item>
        <item name="android:windowBackground">@drawable/ui_loading</item>
    </style>

此时的drawable图片就不能简单的使用一张图片去适配,而要在layer-list中使用这张图,用来填充不同屏幕可能出现的挤压或者拉伸问题。

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"
    android:opacity="opaque">

    <item>
        <shape>
            <solid android:color="@android:color/white"></solid>
        </shape>

    </item>
    <item android:gravity="center">
        <bitmap
            android:gravity="fill"
            android:src="@drawable/launch"
            android:tileMode="disabled"></bitmap>

    </item>
    <item android:gravity="top">
        <bitmap android:src="@drawable/launchpatch"></bitmap>
    </item>

</layer-list>
发布了316 篇原创文章 · 获赞 63 · 访问量 37万+

猜你喜欢

转载自blog.csdn.net/ytfunnysite/article/details/103809078
今日推荐