You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何修改Capacitor混合应用的Android启动页(ic_launcher)背景色

Capacitor Android 启动页背景色修改方案

方法一:通过Capacitor配置文件修改(推荐,无需原生操作)

  • 打开项目根目录的capacitor.config.ts(若为JSON格式则打开capacitor.config.json)
  • 在android配置节点下添加splashScreen配置,指定自定义背景色:
import { CapacitorConfig } from '@capacitor/cli';

const config: CapacitorConfig = {
  appId: 'com.your.app.id',
  appName: 'YourAppName',
  webDir: 'dist',
  android: {
    splashScreen: {
      backgroundColor: "#FF5722", // 替换为你的十六进制颜色值
      // 图标无需修改,保持现有ic_launcher即可
    }
  }
};

export default config;
  • 执行命令同步配置到Android项目:
npx cap sync android

方法二:直接修改Android原生文件(配置不生效时使用)

如果上述方法无效,直接修改Android端的主题或启动页背景资源:

  1. 打开Android项目的app/src/main/res/values/styles.xml
  2. 找到对应启动页的主题(通常为SplashTheme),修改android:windowBackground属性:
<style name="SplashTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="android:windowBackground">#FF5722</item> <!-- 替换为你的自定义颜色 -->
</style>
  1. 若启动页背景是通过layer-list drawable定义(比如res/drawable/splash_background.xml),打开该文件修改背景色:
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="#FF5722" /> <!-- 此处修改背景色 -->
    <item>
        <bitmap
            android:gravity="center"
            android:src="@mipmap/ic_launcher" /> <!-- 保留现有图标,无需改动 -->
    </item>
</layer-list>
  1. 重新构建Android项目即可生效

内容的提问来源于stack exchange,提问作者Joe Schmo

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.10 07:11:02