Created
January 5, 2015 13:21
-
-
Save alorma/b117302a23c61761b2fa to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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