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 :: constraintlayout vs coordinatorlayout 
Java :: 2d array java 
Java :: java check if path exists 
Java :: set layout params in dp value 
Java :: assert multiple junit 
Java :: check if first character of a string is a number java 
Java :: spring boot param object 
Java :: how to break switch case in java 
Java :: min in java 
Java :: Error: Could not find or load main class javafx.controls,javafx.fxml Caused by: java.lang.ClassNotFoundException: javafx.controls,javafx.fxml 
Java :: how to convert kilometers to miles in java 
Java :: map in java 
Java :: socket in java 
Java :: java rename file 
Java :: change status bar text color android programmatically 
Java :: if and else on one line java 
Java :: The this(Keyword) 
Java :: java ignore catch 
Java :: import android.support.v7.app.alertdialog androidx 
Java :: largest number in an array in java 
Java :: actuator spring boot 
Java :: java heckj object lock 
Java :: window in java swing 
Java :: online java code fixer 
Java :: android iterate through radio group java 
Java :: launch java batch 
Java :: java implement interface 
Java :: java how to change the length of an array 
Java :: method parameters in java 
Java :: java anonmyous array eg 
ADD CONTENT
Topic
Content
Source link
Name
5+5 =