Android

android启动大图Logo拉伸解决

2020-11-29  本文已影响0人  卢融霜

APP启动图为了解决白屏、黑屏的问题,最简答的都会设置一张背景图,背景图全宽全高,可能会遇到拉伸的问题,解决思路就是,将拉伸的位置也提取出来,分别放在不同drawable文件夹下。
代码操作如下:
drawable 新建一个资源文件如下:

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

    <item>
        <color android:color="@color/colorPrimary" />
    </item>
    <item>
        <bitmap
                android:gravity="bottom|fill_horizontal|fill_vertical"
                android:src="@drawable/splash_bg" />
    </item>
    <item android:bottom="@dimen/dp_150">
        <bitmap

                android:gravity="center"
                android:src="@drawable/splash_logo" />
    </item>
<!--    <item android:bottom="@dimen/dp_50">-->
<!--        <bitmap-->
<!--                android:gravity="bottom|center"-->
<!--                android:src="@drawable/splash_text" />-->
<!--        />-->
<!--    </item>-->
</layer-list>
image.png image.png
 <item name="android:windowBackground">@drawable/splash_file</item>

这样的话, 背景和logo都会根据分辨率不同,适配适合的文件。

上一篇 下一篇

猜你喜欢

热点阅读