兩個(gè)顏色取中間值 Bitmap中提取突出顏色

兩個(gè)顏色取中間值

ArgbEvaluator.evaluate(float fraction,ObjectstartValue,ObjectendValue);

?????用于根據(jù)一個(gè)起始顏色值和一個(gè)結(jié)束顏色值以及一個(gè)偏移量生成一個(gè)新的顏色

https://developer.android.com/reference/android/animation/ArgbEvaluator.html


Bitmap中提取突出顏色

Palette

?????5.0加入的可以提取一個(gè)Bitmap中突出顏色的類

https://developer.android.com/reference/android/support/v7/graphics/Palette.html

//?Palette的部分?

Palette.generateAsync(bitmap,newPalette.PaletteAsyncListener()?{

/**

?????????*?提取完之后的回調(diào)方法

?????????*/

@Override

publicvoidonGenerated(Palette?palette)?{

????????????Palette.Swatch?vibrant?=?palette.getVibrantSwatch();??

/*?界面顏色UI統(tǒng)一性處理,看起來(lái)更Material一些?*/

????????????mPagerSlidingTabStrip.setBackgroundColor(vibrant.getRgb());??

????????????mPagerSlidingTabStrip.setTextColor(vibrant.getTitleTextColor());??

//?其中狀態(tài)欄、游標(biāo)、底部導(dǎo)航欄的顏色需要加深一下,也可以不加,具體情況在代碼之后說(shuō)明?

????????????mPagerSlidingTabStrip.setIndicatorColor(colorBurn(vibrant.getRgb()));??


????????????mToolbar.setBackgroundColor(vibrant.getRgb());??

if(android.os.Build.VERSION.SDK_INT?>=21)?{

????????????????Window?window?=?getWindow();??

//?很明顯,這兩貨是新API才有的。?

????????????????window.setStatusBarColor(colorBurn(vibrant.getRgb()));??

????????????????window.setNavigationBarColor(colorBurn(vibrant.getRgb()));??

????????????}??

????????}??

????});??

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容