有时候美工给的图标颜色不必定是本身想要的颜色,这个时候就会想,有没有办法不用麻烦美工,本身就能够将颜色改变,具体的方法以下:java
private Drawable setIconColor() { Drawable wrappedDrawable = DrawableCompat.wrap(getActivity().getResources().getDrawable(R.drawable.im_arrow_left)); DrawableCompat.setTintList(wrappedDrawable, ColorStateList.valueOf(Color.parseColor("#000000"))); return wrappedDrawable; }
还能够直接调用ImageView的setcolorFilter方法app
imageview.setcolorFilter(int color);code