Android Change picture background color tint (coloring) or backgroundtint

Source: Internet
Author: User

Android icon coloring to save the APK volume, there are many online introduction, the use is very simple

<imageview android:tint= "@android: Color/white" android:backgroundtint= "@android: Color/black"/>

Usually use this way, you have to change the code today, so record

First Kind

Drawable icon;if (Android.os.Build.VERSION.SDK_INT < Android.os.Build.VERSION_CODES. LOLLIPOP) {icon = Getresources (). getdrawable (R.drawable.ic_back_black);} else{icon = getresources (). getdrawable (R.drawable.ic_back_black, Gettheme ());} Colorfilter filter = new Lightingcolorfilter (Color.White, Color.White); Icon.setcolorfilter (filter); Image.setimagedrawable (icon);

The second kind, need V4 package

Drawable icon1;if (Android.os.Build.VERSION.SDK_INT < Android.os.Build.VERSION_CODES. LOLLIPOP) {icon1 = Getresources (). getdrawable (R.drawable.ic_back_black);} else{Icon1 = Getresources (). getdrawable (R.drawable.ic_back_black, Gettheme ());} drawable Tinticon = Drawablecompat.wrap (icon1);D rawablecompat.settint (Tinticon, color.white);// Drawablecompat.settintlist (Tinticon, Color.White); titleback1.setimagedrawable (Tinticon);

Well, all two can be achieved. I don't know which one is better.

There are a lot of related information online

Http://www.cnblogs.com/helloandroid/p/4779061.html

Http://www.jcodecraeer.com/a/anzhuokaifa/androidkaifa/2016/0128/3923.html


This article is from the "Fly to learn Android" blog, please be sure to keep this source http://qq445493481.blog.51cto.com/9545543/1842972

Android changes the picture background color tint (shading) or backgroundtint

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.