73718363
Used to do a flow of suspended windows, suspended windows with the current network status of the icon and speed of the text, want to change the text color and change the color of the status icon
After the realization of sharing to let everyone refer to the next
First
Here are the key codes
< ImageView Android:id = "@+id/iv_icon" android:layout_width= "150DP" android:layout_height= "150DP" android:src = "@drawable/icon" />
//set the color of the icon
private void seticoncolor (ImageView icon, int R, int G, int B, int a { float [] ColorMatrix = new float []{ 0, 0, 0, 0 0, 0, 0, 0, G, 0, 0, 0, 0, B, 0, 0, 0, (float ) a/255, 0 }; Icon.setcolorfilter ( new Colormatrixcolorfilter (ColorMatrix));}
- Want to know the specific principle can look at this article
Android Learning Note 22: Image Color Processing (ColorMatrix)
If the icon is opaque and does not require a change in transparency, there is a simpler way to implement it.
Icon.setcolorfilter (Color.argb (255, R, G, b));
Android dynamic set color for solid color icons