I have had extended recyclerview, so I can scale it. It works the way I wanted it, but now I wanted to programmatically scroll x the number of pixels. The user story for this is that if I touch the upper half of the screen, it should scroll x pixels, the same applies to the lower half of the screen.
Here is what I did:
Activity:
@Override
public boolean dispatchTouchEvent(MotionEvent event)
{
mScaleDetector.onTouchEvent(event);
if(event.getAction() == MotionEvent.ACTION_DOWN)
{
int y = (int) event.getY();
if(y >= mScreenSize.y / 2)
{
mComicViewerFragment.scrollBy((int)(mScreenSize.y * 0.10f));
Log.i(ComicApplication.TAG, "ComicViewerActivity.onTouchEvent : You are tapping the lower part : " + y);
}
else
{
mComicViewerFragment.scrollBy((int)(-mScreenSize.y * 0.10f));
Log.i(ComicApplication.TAG, "ComicViewerActivity.onTouchEvent : You are tapping the upper part : " + y);
}
}
return super.dispatchTouchEvent(event);
}
Fragment
public void scrollBy(int by)
{
mScalingRecyclerView.smoothScrollBy(0, by);
}
Every time I click, it does not scroll x the number of pixels. Is it because I created a custom view extending from RecyclerView? Where should I properly call smoothScrollBy? It should be easy, but I'm stuck.