一、在 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 为白色,防止图片大小小于页面大小时出现黑边。
本文介绍如何在Android项目中使用XML文件定制启动页背景,并通过定义主题样式实现全屏显示及背景颜色控制,避免图片尺寸不足导致的黑边问题。
1万+

被折叠的 条评论
为什么被折叠?



