Brett Brett - 21 days ago 8
Android Question

Using a font and string as a Drawable

In the spirit of simple vector images on Android that always look sharp, I was wondering if I can't use custom font paired with a string (or a character) as a

Drawable
.

For instance, if I wanted to use a Webdings character as the drawable on a
Button
, how would I do this?

I want the best font size to be selected (using
dip
or
sp
) so that I get no distortion on the image.

Do you have any ideas how I can accomplish this goal?

Thanks!

Answer

You can check out my library IconicTextView It allows to use several iconic fonts to display vector images. Currently a subclass of TextView is used to display them but I'm working on rewriting it to use custom Drawable. The main issue here is selecting the best font size, I'm trying to find a way to auto adjust font size.