Skip to content

Instantly share code, notes, and snippets.

@alorma
Created January 5, 2015 13:21
Show Gist options
  • Save alorma/b117302a23c61761b2fa to your computer and use it in GitHub Desktop.
Save alorma/b117302a23c61761b2fa to your computer and use it in GitHub Desktop.
public void setIconDrawable(@NonNull Drawable iconDrawable) {
if (mIconDrawable != iconDrawable) {
mIcon = 0;
Bitmap bitmap = Bitmap.createBitmap(iconDrawable.getIntrinsicWidth(), iconDrawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
iconDrawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
iconDrawable.draw(canvas);
mIconDrawable = new BitmapDrawable(getResources(), bitmap);
updateBackground();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment