android 5.0新特性學習--Drawable Tinting(為圖片資源著色)

來源:互聯網
上載者:User

標籤:

使用android:tint屬性去調整色調。
android:tintMode 著色模式
screen
multiply
and
src_atop/src_in/src_over
setTint(int tint)
setTint(int tint)的參數,可以是一個@color/下的屬性,也可以是一個xml的selector,selector中的item是使用了數位

<selector xmlns:android="http://schemas.android.com/apk/res/android"><item android:state_focused="true" android:color="@color/testcolor1"/><item android:state_pressed="true" android:state_enabled="false" android:color="@color/testcolor2" /><item android:state_enabled="false" android:color="@color/testcolor3" /><item android:color="@color/testcolor5"/></selector>

 

setColorFilter 同時設定著色顏色和著色模式

從圖片中抽取顏色:
在api21上的support-v7庫中有一個android-support-v7-palette.jar,它能夠讓你從圖片中抽取一些顯眼的顏色:
Palette p = Palette.generate(Bitmap bitmap);
·鮮豔的 p.getVibrantColor(int defaultColor);
·鮮豔的黑暗 p.getDarkVibrantColor(int defaultColor);
·鮮豔的明亮 p.getLightVibrantColor(int defaultColor);
·柔和的 p.getMutedColor(int defaultColor);
·柔和的黑暗 p.getDarkMutedColor(int defaultColor);
·柔和的明亮 p.getLightMutedColor(int defaultColor);
Palette.generate(),用於在後台線程中執行,如果在前台線程中建立Palette對象,那麼可以使用Palette.generateAsync()。

android 5.0新特性學習--Drawable Tinting(為圖片資源著色)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.