Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RecyclerView scrollbar laggy

When I used the new recycler view, I noticed the scrollbar is not as fluid as in regular ScrollView/ListView. It looks like it doesn't recognize when you scroll within the adapter item, but it only changes when new item appears / old item disappears, so the progressbar jumps instead of move smoothly. This is a video demonstrating this issue. Is there a way to make it smooth?

My layout:

<android.support.v7.widget.RecyclerView
                android:id="@+id/listRecycler"
                android:scrollbars="vertical"
                android:layout_width="match_parent"
                android:layout_height="match_parent"/>

Fragment:

    mListRecycler.setAdapter(mAdapter);
    LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
    layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
    mListRecycler.setLayoutManager(layoutManager);

Adapter:

public class NewsAdapter extends RecyclerView.Adapter<NewsAdapter.ViewHolder> {

private List<News> items;
private int itemLayout;

public NewsAdapter(List<News> items, int itemLayout) {
    this.items = items;
    this.itemLayout = itemLayout;
}

@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    View v = LayoutInflater.from(parent.getContext()).inflate(itemLayout, parent, false);
    v.setOnClickListener(this);
    return new ViewHolder(v);
}

@Override
public void onBindViewHolder(ViewHolder holder, int position) {
    News item = items.get(position);
    holder.text.setText(item.getTitle());
    holder.itemView.setTag(item);
}


@Override
public int getItemCount() {
    return items.size();
}

public static class ViewHolder extends RecyclerView.ViewHolder {
    @InjectView(R.id.title)
    TextView text;

    public ViewHolder(View itemView) {
        super(itemView);
        ButterKnife.inject(this, itemView);
    }
}

}

like image 768
martinpelant Avatar asked Aug 15 '14 06:08

martinpelant


1 Answers

this is problem in L preview release. LinearLayoutManager did not have smooth scrollbars support. Will be fixed when RecyclerView is released.

like image 96
yigit Avatar answered Nov 15 '22 08:11

yigit