閱讀191 返回首頁    go 技術社區[雲棲]


Android 離線用戶的灰色頭像處理

主要涉及兩個技術點:

1、圖標加灰色過濾;

2、android的圖片資源默認是靜態的,單實例;如果兩個IM好友的頭像一樣,最簡單的都是用的軟件自帶頭像,有一個在線,一個離線,直接改變頭像的灰度,則兩個用戶的頭像都會變灰或者在線,答案是:Drawable.mutate()。

代碼如下:

Drawable mDrawable = context.getResources().getDrawable(R.drawable.face_icon);
//Make this drawable mutable.
//A mutable drawable is guaranteed to not share its state with any other drawable.
mDrawable.mutate();
ColorMatrix cm = new ColorMatrix();
cm.setSaturation(0);
ColorMatrixColorFilter cf = new ColorMatrixColorFilter(cm);
mDrawable.setColorFilter(cf);


最後更新:2017-04-03 16:48:32

  上一篇:go PHP安裝eAccelerator加速器的配置信息
  下一篇:go 【OpenHW參賽手記】System Generator 與XPS連接的方法