Android and android Official Website

Source: Internet
Author: User

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





Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.