Android and android Official Website
ScrollView add prompt Arrow (Arrow)
Address: http://blog.csdn.net/caroline_wendy
InSlide function of ScrollView, You need to prompt the user, you can slide, you can add two arrows.
Customize ScrollView and create listenerIScrollStateListenerInterface:
private IScrollStateListener scrollStateListener; public void setScrollStateListener(IScrollStateListener listener) { scrollStateListener = listener; } public interface IScrollStateListener { void onScrollMostLeft(); void onScrollFromMostLeft(); void onScrollMostRight(); void onScrollFromMostRight(); }
Call the listener when the listener slides.
OnScrollChanged):
@Override protected void onScrollChanged(int l, int t, int oldl, int oldt) { super.onScrollChanged(l, t, oldl, oldt); if (scrollStateListener != null) { if (l == 0) { scrollStateListener.onScrollMostLeft(); } else if (oldl == 0) { scrollStateListener.onScrollFromMostLeft(); } int mostRightL = this.getChildAt(0).getWidth()-getWidth(); if (l >= mostRightL) { scrollStateListener.onScrollMostRight(); } else if (oldl >= mostRightL && l < mostRightL) { scrollStateListener.onScrollFromMostRight(); } } }
In use
SlideTo
Listen to eventsTo pass specific transactions:
Final ImageView leftArrow = gradient rows); final ImageView rightArrow = export tor_gather_imageview_rightarrow); AutoHorizontalScrollView scrollView = export tor_gather_scrollview); scrollView. setScrollStateListener (new AutoHorizontalScrollView. IScrollStateListener () {@ Override public void onScrollMostLeft () {Log. e (DEBUG + TAG, "leftmost Sliding bar"); leftArrow. setVisibility (View. INVISIBLE); rightArrow. setVisibility (View. VISIBLE) ;}@ Override public void onScrollFromMostLeft () {Log. e (DEBUG + TAG, "slide to the left"); leftArrow. setVisibility (View. VISIBLE); rightArrow. setVisibility (View. VISIBLE) ;}@ Override public void onScrollMostRight () {Log. e (DEBUG + TAG, "rightmost slide bar"); leftArrow. setVisibility (View. VISIBLE); rightArrow. setVisibility (View. INVISIBLE) ;}@ Override public void onScrollFromMostRight () {Log. e (DEBUG + TAG, "slide to the rightmost"); leftArrow. setVisibility (View. VISIBLE); rightArrow. setVisibility (View. VISIBLE );}});
You can.
Reference: http://stackoverflow.com/questions/9062227/how-to-set-images-for-scrollview-instead-of-fading-edges