I am using this code to add sticker from drawables:
`public void addStickerView(String string) {
Drawable drawable =
ContextCompat.getDrawable(context, getResources().getIdentifier(string, "drawable", getPackageName()));
stickerView.addSticker(new DrawableSticker(drawable));
}
public void setColor(int color) {
if(currentSticker instanceof TextSticker){
((TextSticker) currentSticker).setTextColor(color);
} else {
currentSticker.getDrawable().setColorFilter(color, PorterDuff.Mode.MULTIPLY);
}
stickerView.invalidate();
}
public void somefunction(){
addStickerView("image");
// Setting currentSticker as above added sticker
setColor(Color.RED);
addStickerView("image");
}
`
Here I am adding "R.drawable.image" two times, but as per code only first sticker should have red color and other should have default color. But on running, both images have RED color.
Hi,
I am using this code to add sticker from drawables: `public void addStickerView(String string) { Drawable drawable = ContextCompat.getDrawable(context, getResources().getIdentifier(string, "drawable", getPackageName())); stickerView.addSticker(new DrawableSticker(drawable)); } public void setColor(int color) { if(currentSticker instanceof TextSticker){ ((TextSticker) currentSticker).setTextColor(color); } else { currentSticker.getDrawable().setColorFilter(color, PorterDuff.Mode.MULTIPLY); } stickerView.invalidate(); }
public void somefunction(){ addStickerView("image"); // Setting currentSticker as above added sticker setColor(Color.RED); addStickerView("image"); } `
Here I am adding "R.drawable.image" two times, but as per code only first sticker should have red color and other should have default color. But on running, both images have RED color.
Please tell me how to fix it.