Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

recycler view is not scrolling smoothly on lollipop

Tags:

android

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);
}


}

}

like image 666
Abhishek Lodha Avatar asked Dec 13 '25 17:12

Abhishek Lodha


1 Answers

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/

like image 173
Abhishek Lodha Avatar answered Dec 16 '25 08:12

Abhishek Lodha



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!