有時候美工給的圖標顏色不必定是本身想要的顏色,這個時候就會想,有沒有辦法不用麻煩美工,本身就能夠將顏色改變,具體的方法以下: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