Android pixel "Roboto Light"

I include the Roboto font family in my application and create the fonts in the code like this:

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

I noticed that some smaller sizes (even the suggested sizes on the Android Developer Page ) appear distorted or pixelated. Here is a screenshot of several TextView in the application:

roboto_pixelated

Upcoming Dates uses a larger size and looks great. Other ones are 14sp in size and look awful. The problem is not that marker or padding in TextView - I tried changing both. Does anyone know what causes this problem and how to fix it?

+8
android fonts typography
source share
1 answer

Try the following on each of your custom font text elements:

 int flags = textView.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG; textView.setPaintFlags(flags); 
+8
source share

All Articles