Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

change drawable color programmatically android


//resource
Drawable unwrappedDrawable = AppCompatResources.getDrawable(context, R.drawable.my_drawable); 
Drawable wrappedDrawable = DrawableCompat.wrap(unwrappedDrawable);
DrawableCompat.setTint(wrappedDrawable, Color.RED);    

//activity
Drawable unwrappedDrawable = tvContinue.getBackground();
Drawable wrappedDrawable = DrawableCompat.wrap(unwrappedDrawable);
DrawableCompat.setTint(wrappedDrawable, (Color.parseColor(getPreferences().getString(Constant.SECOND_COLOR, Constant.SECONDARY_COLOR))));

//adapter
Drawable unwrappedDrawable = holder.tvOff.getBackground();
 Drawable wrappedDrawable = DrawableCompat.wrap(unwrappedDrawable);
 DrawableCompat.setTint(wrappedDrawable, (Color.parseColor(((BaseActivity) activity).getPreferences().getString(Constant.SECOND_COLOR, Constant.SECONDARY_COLOR))));


//

Comment

change color of drawable android studio

public static Drawable setTint(Drawable d, int color) {
    Drawable wrappedDrawable = DrawableCompat.wrap(d);
    DrawableCompat.setTint(wrappedDrawable, color);
    return wrappedDrawable;
}
Comment

how to change color of drawable in android

Drawable unwrappedDrawable = AppCompatResources.getDrawable(context, R.drawable.my_drawable); 
Drawable wrappedDrawable = DrawableCompat.wrap(unwrappedDrawable);
DrawableCompat.setTint(wrappedDrawable, Color.RED);  
Comment

how to change color of drawable in android

 Drawable unwrappedDrawable = tvContinueShopping.getBackground();
        Drawable wrappedDrawable = DrawableCompat.wrap(unwrappedDrawable);
        DrawableCompat.setTint(wrappedDrawable, (Color.parseColor(getPreferences().getString(Constant.SECOND_COLOR, Constant.SECONDARY_COLOR))));
Comment

PREVIOUS NEXT
Code Example
Java :: using buidfeatures to enable viewbinding 
Java :: system.out.println in java 
Java :: jagged array java 
Java :: java number 
Java :: how to make hello world in java 
Java :: Arraylist string to character java 
Java :: how to create immutable list java 
Java :: open camera in android 
Java :: offsetdattime to date 
Java :: how to truncate decimals in java 
Java :: .now() java 
Java :: create a toast message in android 
Java :: how to set spinner value in android 
Java :: char default value in java 
Java :: java resource file 
Java :: how to crate an array of integers in java 
Java :: java localtime format 
Java :: how to convert bitmap to uri in android 
Java :: open file java 
Java :: war file vs jar file 
Java :: java scanner 
Java :: jframe visible 
Java :: main methode java 
Java :: copy to clipboard android studio 
Java :: java split string 
Java :: how to declare an array in java 
Java :: android java xml combo box 
Java :: how to import math lib in java 
Java :: java format use same value multiple times 
Java :: changer version java terminal 
ADD CONTENT
Topic
Content
Source link
Name
3+8 =