Frage

I'm including the Roboto family of fonts in my application, and create the fonts in code like so:

Typeface robotoLight = Typeface.createFromAsset(getAssets(), "fonts/Roboto-Light.ttf");

I have noticed that certain smaller sizes (even the suggested sizes from the Android Developer Typography page) appear distorted or pixelated. Here is a screenshot of a few TextViews in the app:

roboto_pixelated

"Upcoming Dates" uses a larger size and looks fine. The other ones are sized at 14sp and look awful. The problem is not with margin or padding in the TextViews -- I've tried altering both. Does anyone know what causes this problem, and how to fix it?

War es hilfreich?

Lösung

Try the following on each of your TextViews with the custom typeface:

int flags = textView.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG
            | Paint.ANTI_ALIAS_FLAG;
textView.setPaintFlags(flags);
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top