public static void tint ( View view , Tint tint ) { final ColorStateList color = tint . getColor ( view . getContext ( ) ) ; if ( view instanceof ImageView ) { tint ( ( ( ImageView ) view ) . getDrawable ( ) , color ) ; } else if ( view instanceof TextView ) { TextView text = ( TextView ) view ; Drawable [ ] comp = text . getCompoundDrawables ( ) ; for ( int i = 0 ; i < comp . length ; i ++ ) { if ( comp [ i ] != null ) { comp [ i ] = tint ( comp [ i ] , color ) ; } } text . setCompoundDrawablesWithIntrinsicBounds ( comp [ 0 ] , comp [ 1 ] , comp [ 2 ] , comp [ 3 ] ) ; } else { throw new IllegalArgumentException ( "Unsupported view type" ) ; } }
Tints ImageView drawable or TextView compound drawables to given tint color .