Code example for HorizontalScrollView

Methods: smoothScrollTo, getScrollX, getWidth

0
 
	/** 
	 * does the effect "forward a page" 
	 */ 
	public void next() { 
		int pageWidth = mScroll.getWidth();
		int nextPage = (mPageActive + 1) * pageWidth;
		if (nextPage - mScroll.getScrollX() <= pageWidth) {
			mScroll.smoothScrollTo(nextPage, 0);
			mPageActive++;
		} else { 
			mScroll.smoothScrollTo(mScroll.getScrollX(), 0);
		} 
	} 
 
	/** 
	 * Private class that controls the gestures, forward or back a page. 
	 */ 
	private class MySimpleOnGestureListener extends SimpleOnGestureListener {
 
		@Override