隨筆-1  評(píng)論-68  文章-98  trackbacks-0

          編寫(xiě):徐建祥(netpirate@gmail.com)

          日期:2010/11/22

          網(wǎng)址:http://www.anymobile.org

          主要涉及兩個(gè)技術(shù)點(diǎn):

          1、圖標(biāo)加灰色過(guò)濾;

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

          代碼如下:

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

           

          OVER!

          posted on 2010-12-14 23:08 Xu Jianxiang 閱讀(521) 評(píng)論(0)  編輯  收藏 所屬分類: Android
          主站蜘蛛池模板: 武汉市| 体育| 石嘴山市| 嵊州市| 石阡县| 德化县| 华宁县| 沁阳市| 平罗县| 德惠市| 太湖县| 连江县| 宽城| 泰安市| 当涂县| 江陵县| 中方县| 武鸣县| 南充市| 龙南县| 浦东新区| 新沂市| 山阴县| 屏东市| 灵川县| 进贤县| 彭水| 瓮安县| 都昌县| 临泽县| 胶南市| 达孜县| 平定县| 改则县| 绥中县| 丹江口市| 陕西省| 武安市| 桦甸市| 竹山县| 临沭县|