I implement auto scroll on RecyclerView to display like running text using smoothScrollToPosition. And it is working.
public void autoScroll() {
final int speedScroll = 1000;
runnableRunningAds = new Runnable() {
@Override
public void run() {
rcRunningTextAds.smoothScrollToPosition(runningTextAdsAdapter.getItemCount());
blnRunningAdsIsRunning = true;
handlerRunningAds.postDelayed(this, speedScroll);
}
};
handlerRunningAds.postDelayed(runnableRunningAds, speedScroll);
}
The problem is it stop scrolling when user touch the RecyclerView. I was already try this, but it is still not working. The RecyclerView still stop scrolling.
Any idea about it? Thanks.
Try Using post delayed to work in a separate thread
private void disableTouch(){
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
recyclerView.addOnItemTouchListener(new
RecyclerView.SimpleOnItemTouchListener() {
@Override
public boolean onInterceptTouchEvent(RecyclerView rv,
MotionEvent e) {
// true: consume touch event
// false: dispatch touch event
return true;
}
});
}
}, 500);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.