0

I use this code to set Roboto font to a Textview for each item if my list.

It works fine but when i scrolml the list, it's not fluid whereas with default font, the list is verry fluid when i scroll.

TextView premiereLettre = (TextView) rowView.findViewById(R.id.premiere_lettre);
Typeface face = Typeface.createFromAsset(getContext().getAssets(), "fonts/Roboto-Light.ttf");
premiereLettre.setTypeface(face);

What is the problem ?

Can i make an enhancement for this code ?

Thanks a lot

wawanopoulos
  • 9,614
  • 31
  • 111
  • 166

1 Answers1

2

Problem is that you create TextView object, and most importantly a Typeface object each time you create a row. Create them once in your class (you can use ViewHolder for your TextView, and a class level variable for Typeface that you instantiate in your constructor)

Mohamed_AbdAllah
  • 5,311
  • 3
  • 28
  • 47