MTK Theme

本文详细介绍了如何在MediaTek设备上配置主题资源,包括修改模块资源、添加资源、编译主题并应用到系统框架中。同时提供了常见FAQ解答及系统主题管理相关代码示例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1,配置alps\frameworks\base\data\etc\thememap.xml 注册需要修改的模块中的相关资源


ic_launcher_sim_toolkit.png

其中
name是模块名即LOCAL_PACKAGE_NAME对应的值
path是该模块编译后的路径 如”/system/app/StkSelection.apk” ,”/system/priv-app/Settings.apk”
ic_launcher_sim_toolkit.png ic_launcher_sim_toolkit.png是要修改的资源名称

2,添加资源
在alps/mediatek/frameworks/themes/theme-res-xxx/下新建一个文件夹,名为stkselection(全部小写),要修改的图片为ic_launcher_sim_toolkit.png,
则在alps/mediatek/frameworks/themes/theme-res-xxx/stkselection/建立drawable-xhdpi drawable-hdpi drawable-mdpi放入相应尺寸的ic_launcher_sim_toolkit.png,以作适配。
如果要修改的图片在mipmap-xxx下,则需建立mipmap-xdpi mipmap-hdpi mipmap-mdpi并放相应尺寸图片资源

3,编译alps/mediatek/frameworks/themes/theme-res-xxx/该主题,生成对应apk,push到system/framework下即可。
编译过程中会调用copy_res.pl脚本,此脚本就是将alps/mediatek/frameworks/themes/theme-res-xxx/下各个模块下的资源都拷贝到
alps/mediatek/frameworks/themes/theme-res-xxx/下的res中去。最终将res打包为apk。
如:StkSelection这个模块
|–>drawable-hdpi–>ic_launcher_sim_toolkit.png |–>drawable-hdpi–>stkselection_ic_launcher_sim_toolkit.png
StkSelection–>res–>| 经过脚本后拷贝到–>theme-res-xxx/res–>|
|–>drawable-xhdpi_>ic_launcher_sim_toolkit.png |–>drawable-xhdpi->stkselection_ic_launcher_sim_toolkit.png
故可以按照命名规则将所有需要修改的资源按照尺寸放到theme-res-xxx/res/相应的文件夹中即可。

4,每套Theme由alps/mediatek/frameworks/themes/theme-res-xxx/编译生成一个apk。
alps/mediatek/frameworks/themes/theme-res-xxx/AndroidManifest.xml中的
package=”com.mediatek.theme.one” —>该Theme包名
mtk:isThemePackage=”1” —>系统通过该属性来判断该apk是否为主题apk
mtk:themeNameId=”@string/theme_name” —>主题名称
每套主题的一个preview是在名字为previewtheme.png Resource.java中有接口获取

5,[FAQ10382]对于mediatek的资源,使其跟随theme切换而切换
[FAQ10343]对于第三方预置可卸载的apk,如何客制化其在主题中的资源
[FAQ07085]如何设定默认主题

注:DownloadProviderUi在DownloadProvider下附带编译生成的,因为alps\build\target\product\common.mk中没有声明该模块,
再按上面方法添加DownloadProviderUi的图标时所有拷贝都不会执行。此时只能按照命名规则直接将ic_launcher_download.png修改为
downloadproviderui_ic_launcher_download.png放到alps/mediatek/frameworks/themes/theme-res-xxx/res/mipmap-hdpi下即可

6,系统原生的ThemeManager的相关代码在alps\packages\apps\Settings\src\com\mediatek\thememanager\中
里面有获取系统中所有theme的方法,以及设置Theme的方法。
如果想修改Launcher中所有图标,当切换主题后不能马上生效,需要重启Launcher可以见效。

7,仅当MTK_THEMEMANAGER_APP=yes时ThemeManager才会正常工作。
内置theme说明:
a. 对比thememap.xml,在alps\mediatek\frameworks\下建themes文件夹,并将theme-res-one,theme-res-two,theme-res-three放到themes下
b. 修改alps\build\target\product\common.mk中
ifeq ((strip(MTK_THEMEMANAGER_APP)), yes)
PRODUCT_PACKAGES += theme-res-mint \
theme-res-mocha \
theme-res-raspberry \
libtinyxml
endif

ifeq ((strip(MTK_THEMEMANAGER_APP)), yes)
PRODUCT_PACKAGES += theme-res-one \
theme-res-two \
theme-res-three \
libtinyxml
endif
c. 获取系统中的Theme,或设置theme参考Demo–>MyThemeManager2

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值