Ad

How Do I Draw Android.graphics.drawable.Icon On Canvas?

- 1 answer

I'm startled. I was sure Icon will behave an any other drawable. But I don't see any draw or setBounds methods. I can't find any examples of outputting Icon(lot of them for creating one from bitmap). How do I draw something I have as android.graphics.drawable.Icon on canvas in specific place?

Ad

Answer

you can use loadDrawable(Context context) method to get a Drawable object as mentioned in the official documentation

Returns a Drawable that can be used to draw the image inside this Icon, constructing it if necessary. Depending on the type of image, this may not be something you want to do on the UI thread, so consider using loadDrawableAsync instead.

Context: Context in which to load the drawable; used to access Resources, for example.

Returns : A fresh instance of a drawable for this image, yours to keep.

Ad
source: stackoverflow.com
Ad