Android启动页图片适配

一、在 drawable 中创建一个 xml 文件:splah.xml

<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
    android:src="@drawable/app_welcom_bg1"
    android:dither="true"
    android:filter="true"
    android:antialias="true"
    android:gravity="center">
</bitmap>

传送门:BitmapDrawable (可控制对齐平铺的图像)

二、设置启动页主题

<!--***************启动页Theme***************-->
<style name="Theme.welcome" parent="AppTheme">
    <item name="android:windowFullscreen">true</item>
    <item name="android:background">@drawable/splah</item>
    <item name="android:windowBackground">@color/common_color_white</item>
    <item name="android:windowDrawsSystemBarBackgrounds">false</item>
</style>

设置 splah.xml 为启动页背景,设置 windowBackground 为白色,防止图片大小小于页面大小时出现黑边。


版权声明:本文为androidzf原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。