Lag while switching between tabs.

  • Replies:4
  • Forum posts: 3

Mar 23, 2016, 2:01:58 PM via Website


From GIF you can check how it lags when I switch to left tab because here drawing of image is taking more time if I am not wrong. In other tab images are less so it has no lag but it will surely do, once RecyclerView adds more items (using an adapter). Each item is made using RelativeLayout have 2 TextView, ImageView and ImageButton.
I checked doing the same without loading any images - it works super fast without lag so now it's sure that drawing images is a problem here. I tried LruCache but it didn't solve the problem. Those two tabs are two fragments inside a ViewPager.
Any solution?

— modified on Mar 23, 2016, 4:02:58 PM

  • Forum posts: 3

Mar 23, 2016, 6:41:16 PM via Website

Thanks for help. I tried Picasso but it still lags. It's so smooth when I run this on my smart-phone (Micromax A110) with or without Picasso but when I run it on emulator it starts lagging, also it lags in pretty well know device, Samsung S5 running Android 5.0.

  • Forum posts: 266

Mar 23, 2016, 8:13:39 PM via Website

With Picasso, did you do something like this?

static class ImageAapter extends ArrayAdapter<File> {

LayoutInflater mInflater;
Picasso mPicasso;

public ImageAapter(Context context, File[] objects) {
  super(context, R.layout.list_item, objects);
  mInflater = LayoutInflater.from(context); 
  mPicasso = Picasso.with(context);

public View getView(int position, View convertView, ViewGroup parent) {
  View view = convertView;
  if (view == null) {
    view = mInflater.inflate(R.layout.list_item, parent, false);
  ImageView imageView = (ImageView) view.findViewById(;

mPicasso.load(getItem(position)).resizeDimen(R.dimen.image_size, R.dimen.image_size). centerInside().into(imageView);

  return view;


  • Forum posts: 3

Mar 23, 2016, 8:39:38 PM via Website

Similar to this, but it didn't work, I think I should not use ViewPager, may be Picasso is doing what it is meant for, but here issue is something else I guess, rather I should use some other way of implementing tabs. Thanks anyways. :)