简体   繁体   中英

Android listview is not fluid when i use font from Assets

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

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM