Colormatrixcolorfilter Color filter (Gray avatar processing for offline users)

Source: Internet
Author: User

Android image resources By default is static, single instance; if two im friends have the same avatar, the simplest is to use the software comes with the Avatar, there is an online, a offline, directly change the grayscale of the Avatar, then two users of the avatar will be gray or online, the answer is: drawable.mutate ( )。
drawable mdrawable = context.getresources (). getdrawable (R.drawable.face_icon);    // Make this drawable mutable.    // A mutable drawable is guaranteed    to not share it state with any other drawable. mdrawable.mutate ();    New ColorMatrix ();   Cm.setsaturation (0);    New colormatrixcolorfilter (cm);   Mdrawable.setcolorfilter (CF);  

Transferred from: http://gundumw100.iteye.com/blog/1126129

Colormatrixcolorfilter Color filter (Gray avatar processing for offline users)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.