android


Recyclerview lags on scroll if custom font is used


To set a custom font I have created a CutomTextView by extending TextView but the RecyclerView lags while scrolling when the CutomTextView is used. I have tried using a standard Textview and setting the font in the ViewHolder but the result is the same.
CustomTextView.java
public class CustomTextView extends TextView {
public CustomTextView(Context context) {
super(context);
applyCustomFont(context);
}
public CustomTextView(Context context, AttributeSet attrs) {
super(context, attrs);
applyCustomFont(context);
}
public CustomTextView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
applyCustomFont(context);
}
private void applyCustomFont(Context context) {
setTypeface(Typeface.createFromAsset(context.getAssets(), "fonts/hell.ttf"));
}
}
Adapter.java
public class DashBoardAdapter extends RecyclerView.Adapter<DashBoardAdapter.ViewHolder> {
private List<PatientList> patientListList;
private Activity activity;
public DashBoardAdapter(List<PatientList> patientListList, Activity activity) {
this.patientListList = patientListList;
this.activity = activity;
}
#Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(activity).inflate(R.layout.recyclerview_dashboard_row, parent, false);
return new ViewHolder(view);
}
#Override
public void onBindViewHolder(ViewHolder holder, final int position) {
final PatientList p = patientListList.get(position);
if(p.getName() != null)
holder.username.setText(p.getName());
}
#Override
public int getItemCount() {
return patientListList.size();
}
class ViewHolder extends RecyclerView.ViewHolder{
#BindView(R.id.patient_username) TextView username;
private View itemView;
public ViewHolder(View itemView) {
super(itemView);
this.itemView = itemView;
ButterKnife.bind(this,itemView);
// Setting font here when custom textview is not used
}
}
#Override
public int getItemViewType(int position) {
return position;
}
what could be the reason for the lag?

Related Links

how to use colorpicker with my application?
cannot receive new created chats when adding custom IQProvider to Asmack
android, RESULT_OK forcing for Intent.ACTION_VIEW
How to show notification number in Android Application Launcher icon [duplicate]
How to show navigation route on Google Map? [duplicate]
libusb: failed to get configuration descriptor on Android
Disable credit card payment option in paypal integration
Disable button with button selector
Save and restore data in a Fragment
Opening a url from another url using Intent?
Date and time to milliseconds in Android
Run a process in background in Android
Convert String to date in android
Show a custom button on ActionBarSherlock to show a Sliding menu
Overlay GLSurfaceView over the ImageView in android
KSOAP2 returning a error while trying to pass a path as a property

Categories

HOME
sonarqube
url-redirection
api
merge
apache-jena
google-spreadsheet
angular-formly
battery
jwplayer
tail
hugo
regular-language
crystal-lang
qpython
minecraft-forge
pybossa
scrolltop
gmm
squashfs
postscript
object-storage
aggregation
google-api-client
xcode-ui-testing
datastax-enterprise-graph
jaws
alm
mobx
card.io
sammy.js
reactjs.net
servicestack-text
sharepoint-workflow
magento-1.9.2.4
docfx
wurfl
z-notation
railstutorial.org
health-monitoring
metaprogramming
microsoft-metro
outputcache
rfc3339
monkey-testing
payara-micro
context-switch
appdomain
modelsim
google-photos
cd-burning
renaming
donations
stripe-connect
async.js
windows-azure-queues
ng-grid
lz77
nupic
phpgrid
grgit
qt5.2
xenomai
google-books
zen-cart
mmwormhole
angular-gettext
punycode
koala
scriptaculous
c++builder-xe5
cardreader
http-status-code-410
booksleeve
joomla3.1
qi4j
pyunit
pinch
update-statement
listactivity
massive
cac
instantiationexception
scrollbars
request-headers
skype4java
cldc
software-lifecycle
localizable.strings
application-planning

Resources

Encrypt Message