Below is my implementation of onScroll in the SimpleGestureDetector.
This has worked on the droid x, droid, nexus and nexus s, but it
doesn't work on the Xoom running 3.0 of course. On the xoom it is
cause some form of trailing artifact where the image doesn't fully
redraw or i can't fully grab the image.

Here's an image of what this look like. 
http://www.flickr.com/photos/12331779@N08/5575349190/

My initial thoughts are that it might have something to do with the
xoom default landscape over portrait. But using the Log.v below i can
see that the data is what i expect it to be more or less i guess. Any
thoughts on the issue would be helpful. Thanks

public boolean onScroll(MotionEvent e1, MotionEvent e2,
                                float distanceX, float distanceY) {
                        float values[] = new float[9];
                        matrix2.getValues(values);
                        Matrix temp = new Matrix();
                        temp.set(matrix2);
                        float transx = values[Matrix.MTRANS_X];
                        float transy = values[Matrix.MTRANS_Y];
                        float scale = values[Matrix.MSCALE_X];
                        Drawable d = getDrawable();


                        if(d != null){
                                if(WIDTH == 0){
                                        WIDTH = 
getDrawable().getIntrinsicWidth();
                                }
                                if(HEIGHT == 0){
                                        HEIGHT = 
getDrawable().getIntrinsicHeight();
                                }

                                float width = WIDTH * scale;
                                float height = HEIGHT * scale;

                                float originX = 0;
                                float originY = 0;
                                float bigWidth = getWidth();
                                float bigHeight = getHeight();

                                RectF rect = new RectF(0,0,WIDTH,HEIGHT);
                                Log.v("INFO",rect.toString());

                                temp.mapRect(rect);

                                Log.v("INFOMATRIX",rect.toString());
                                Log.v("BIG", bigWidth + " " + bigHeight);
                                Log.v("NORMAL", width + " " + height);
                                Log.v("TRANS", (transx + -distanceX) + " " 
+(transy + -
distanceY));

                                transx = rect.left;
                                transy = rect.top;
                                width = rect.right - rect.left;
                                height = rect.bottom - rect.top;

                                Log.v("NORMAL", width + " " + height);
                                Log.v("TRANS", (transx + -distanceX) + " " 
+(transy + -
distanceY));

                                if((transx + -distanceX) + width < 
bigWidth-CROP_REGION && -
distanceX < 0 && (transx + -distanceX) < (originX+CROP_REGION)){
                                        distanceX = 0;
                                }
                                if((transy + -distanceY) + height < 
bigHeight-CROP_REGION && -
distanceY < 0 && (transy + -distanceY) < (originY+CROP_REGION)){
                                        distanceY = 0;
                                }
                                if((transy + -distanceY) > 
(originY+CROP_REGION) && -distanceY > 0
&& (transy + -distanceY) + height > bigHeight-CROP_REGION){
                                        distanceY = 0;
                                }
                                if((transx + -distanceX) > 
(originX+CROP_REGION) && -distanceX > 0
&& (transx + -distanceX) + width > bigWidth-CROP_REGION){
                                        distanceX = 0;
                                }

                                matrix2.set(savedMatrix);
                                matrix2.postTranslate(-distanceX, -distanceY);
                                setImageMatrix(matrix2);
                                return true;
                        }
                        return false;
                }



Output of the logs:

original image
V/INFO    ( 7588): RectF(0.0, 0.0, 2592.0, 1944.0)
scale and moved using matrix
V/INFOMATRIX( 7588): RectF(37.0, 308.0, 837.0, 908.0)
imageview size specs
V/BIG     ( 7588): 800.0 1070.0
normal scrolling
V/NORMAL  ( 7588): 800.0 600.0
V/TRANS   ( 7588): 45.0 308.0
if image is rotate would be different than above
V/NORMAL  ( 7588): 800.0 600.0
V/TRANS   ( 7588): 45.0 308.0

V/INFO    ( 7588): RectF(0.0, 0.0, 2592.0, 1944.0)
V/INFOMATRIX( 7588): RectF(37.0, 308.0, 837.0, 908.0)
V/BIG     ( 7588): 800.0 1070.0
V/NORMAL  ( 7588): 800.0 600.0
V/TRANS   ( 7588): 39.5 307.5
V/NORMAL  ( 7588): 800.0 600.0
V/TRANS   ( 7588): 39.5 307.5

-- 
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