Hi, maybe you can attach a simple SimpleOnGestureListener to the
HorizontalScrollView and override the onScroll method to act when
scrolling happens.

Sample (untested coding):

//Assuming that you have horizontalScrollView1 and
horizontalScrollView2 defined.

gestureDetector = new GestureDetector(new MyGestureDetector());
gestureListener = new View.OnTouchListener() {
        public boolean onTouch(View v, MotionEvent event) {
                if (gestureDetector.onTouchEvent(event)) {
                        return true;
                }
                return false;
        }
};

horizontalScrollView1.setOnTouchListener(gestureListener);

//Inside your activity, define a custom SimpleGestureListener
class MyGestureDetector extends SimpleOnGestureListener {

        // Override the onScroll event to capture the coordinate
        @Override
        public abstract boolean onScroll (MotionEvent e1, MotionEvent e2,
float distanceX, float distanceY)
                try {

                        // Capture the current positing of scrollView1
                        int scrollX = horizontalScrollView1.getScrollX;
                        int scrollY = horizontalScrollView1.getScrollY;

                        // Scroll scrollView2 to the same position
                        horizontalScrollView2.post(new Runnable() {
                                public void run() {
                                        horizontalScrollView2.scrollTo(scrollX, 
scrollY);
                                }
                        });

                } catch (Exception e) {
                        // nothing
                }
                return false;
        }

}

On Aug 11, 10:10 pm, Thibaut <aar...@gmail.com> wrote:
> Hello,
>
> I'm trying to develop a scrollable dot chart to represent temporal
> events.
>
> There are 2 HorizontalScrollViews in my layout.
> I want the one above updates his position if the user changes the
> position of the one below.
> Is there any listener or anything else that can help me? I didn't find
> anything about that...
>
> Thanks in advance,
>
> Thibaut

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to