Skip to content Skip to sidebar Skip to footer

How Should I Implement Scrolling ?

I have implemented custom relative layout where zoom is happening using ScaleGestureListener also it zooms out on double tap listener. Now I want to implement Pan in my custom rela

Solution 1:

I have achieved it by myself only using onScroll method this also keeps image in a bound area.. Here is the code

@Overridepublic boolean onScroll(MotionEvent e1, MotionEvent e2,
                    float distanceX, float distanceY) {

                    int distX= (int) distanceX, distY =(int) distanceY;

        //Log.d("Print"," X " + this.mClipBound.left +" Y " + this.mClipBound.right + " b "+ this.mClipBound.bottom + " g" + this.mClipBound.top) ;

        Log.d("Print", "Scroll X " + distanceX + " Y " + distanceY);    

                if(this.mClipBound.left<=0)
                    this.scrollTo(-280, 0);
                elseif(this.mClipBound.top<=0)
                    this.scrollTo(0, -250);
                    elseif (this.mClipBound.right>=1047)
                        this.scrollTo(280, 0);
                    elseif (this.mClipBound.bottom>=800)
                        this.scrollTo(0, 250);
                    elsethis.scrollBy((int)distanceX,(int)distanceY);


                    returntrue;

            }

Offset of the hit area after zoom can be calculated - (event.getX() / ZoomLayout.mScaleFactor + ZoomLayout.mClipBound.left) But i have not still figured out the offset of hit area after zooming and scrolling .

Post a Comment for "How Should I Implement Scrolling ?"