public ViewHolder(final View itemView) {
super(itemView);
item_bg = itemView.findViewById(R.id.item_bg);
}
}
}
2.控制smoothScrollToPosition的滑动速度
参考RecyclerView调用smoothScrollToPosition() 控制滑动速度,修改MILLISECONDS_PER_INCH的值即可
/**
- 更改RecyclerView滚动的速度
*/
public class ScollLinearLayoutManager extends LinearLayoutManager {
private float MILLISECONDS_PER_INCH = 25f; //修改可以改变数据,越大速度越慢
private Context contxt;
public ScollLinearLayoutManager(Context context) {
super(context);
this.contxt = context;
}
@Override
public void smoothScrollToPosition(RecyclerView recyclerView, RecyclerView.State state, int position) {
LinearSmoothScroller linearSmoothScroller =
new LinearSmoothScroller(recyclerView.getContext()) {
@Override
public PointF computeScrollVect