I have a RecyclerView which displays an image, a few textviews and 2 imageButtons. The program works absolutely fine for android 4.4.4 and below but it isnt scrolling smoothly on lollipop.
There is some sort of lag/jerk that feels while scrolling in lollipop. I searched to reduce the scroll speed by overriding the fling method, bu there appears to be no such method for my problem.
public class RecyclerViewAdapter extends RecyclerView.Adapter<RecyclerViewAdapter.CustomViewHolder> {
@Override
public RecyclerViewAdapter.CustomViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
if (viewType == TYPE_ITEM) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.recycler_view, parent, false);
return new CustomViewHolder(view, viewType);
} else if (viewType == TYPE_HEADER) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.header, parent, false);
return new CustomViewHolder(view, viewType);
}
return null;
}
@Override
public void onBindViewHolder(final RecyclerViewAdapter.CustomViewHolder holder, int position) {
if (holder.Holderid == 1) {
final MenuDescription menu = listOrder.get(position - 1);
Glide.with(context).load(menu.getFlag_path()).placeholder(R.drawable.ic_order_now).fitCenter().into(holder.image);
}
}
@Override
public int getItemCount() {
return (null != listOrder ? listOrder.size() + 1 : 0);
}
}
}
Problem solved. I was setting the font for very textview from the adapter class which seems to consume way too much RAM. Instead setting the font using setTypeface method, I created a custom textview and setting its typeface from XML.
http://www.techrepublic.com/article/pro-tip-extend-androids-textview-to-use-custom-fonts/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With