generateAsync is deprecated

本文解决了一个关于Android开发中Palette生成方法被废弃的问题,通过将已弃用的generateAsync方法替换成新的Palette.from方法来实现背景颜色的动态设置。

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

final AppBarLayout appBarLayout = (AppBarLayout) findViewById(R.id.app_bar);
Bitmap bitmap = BitmapFactory.decodeResource(getResources(),R.mipmap.ic_launcher_round);
Palette.generateAsync(bitmap, new Palette.PaletteAsyncListener() { @Override public void onGenerated(Palette palette) { Palette.Swatch swatch = palette.getVibrantSwatch(); if(null != swatch) { appBarLayout.setBackgroundColor(swatch.getRgb()); } }

});

出现提示'generateAsync(android.graphics.Bitmap,android.support.v7.graphics.Palette.PaletteAsyncListener)' is deprecated

发现generateAsync方法已经被废弃,用下面方法替换

Palette.from(bitmap).generate(new Palette.PaletteAsyncListener() {
    @Override
    public void onGenerated(Palette palette) {
        Palette.Swatch swatch = palette.getVibrantSwatch();
        if(null != swatch) {
            appBarLayout.setBackgroundColor(swatch.getRgb());
        }
    }
});

PS F:\运维服务中心\闽电通\code\mdt\mall-portal> npm run generate > TourismFontend@1.0.0 generate > cross-env NODE_ENV=production nuxt generate WARN transition property is deprecated in favor of pageTransition and will be removed in Nuxt 3 11:59:21 WARN mode option is deprecated. You can safely remove it from nuxt.config 11:59:21 ERROR (node:8528) [DEP0040] DeprecationWarning: The punycode module is deprecated. Please use a userland alternative instead. 11:59:22 (Use node --trace-deprecation ... to show where the warning was created) [11:59:22] FATAL Path F:/运维服务中心/闽电通/code/mdt/mall-portal/baidu_verify_code-sydjUCTBcS.html is not in cwd F:\运维服务中心\闽电通\code\mdt\mall-portal at ensureAbsolutePathForCwd (node_modules\globby\gitignore.js:55:9) at node_modules\globby\gitignore.js:62:55 at node_modules\globby\index.js:135:47 at Array.filter (<anonymous>) at module.exports (node_modules\globby\index.js:135:30) at async snapshot (node_modules\@nuxt\cli\dist\cli-generate.js:152:17) at async ensureBuild (node_modules\@nuxt\cli\dist\cli-generate.js:71:32) at async Object.run (node_modules\@nuxt\cli\dist\cli-generate.js:234:7) at async NuxtCommand.run (node_modules\@nuxt\cli\dist\cli-index.js:356:7) ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │ │ │ ✖ Nuxt Fatal Error │ │ │ │ Error: Path F:/运维服务中心/闽电通/code/mdt/mall-portal/baidu_verify_code-sydjUCTBcS.html is not in cwd │ │ F:\运维服务中心\闽电通\code\mdt\mall-
03-15
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值