[英]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. 如果我的列表,我使用此代码将Roboto字体设置为每个项目的Textview。
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. 问题是您每次创建一行时都创建
TextView
对象,最重要的是创建一个Typeface
对象。 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) 在类中创建它们一次(您可以将
ViewHolder
用于TextView
,并在构造函数中实例化Typeface
的类级变量)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.