开发者

Android imageview scaletype matrix not modifying image first execution

I have an imageview that I am attemtping to scale on doubletap..

The code runs everytime and properly runs the right condition, make small when its big and make big when its small...

The odd thing is though, the first time the code is run, it shows its running the getsmall, but the image itself never shrinks.. The second time it runs the scale to big, which I have no idea if this works or not since the image is already large before that execution.. but on the third execution it again runs the make small condition, and the image scales small, and from that point onward the image scales bigger and smaller on the screen as expected.

This imageview is instnatiated with a scaletype of CENTER, and yes minScale has a value other than 1 the first time it tries to shrink.. in fact log shows its value to be 0.26... So its not that the minScale is zero first time through.

            @Override
        public boolean onDoubleTap(MotionEvent e) {
            // TODO Auto-generated method stub
            setScale(globalIV);

            System.out.println("DOUBLE TAP "+minScale);
            Matrix mtrx = new Matrix();
            if(!small){
                System.out.println("MAKING SMALL");
                       mtrx.postScale(minScale, minScale);                                          small=true;
            }
            else{
                            mtrx.postScale(1, 1);
                mtrx.postTranslate(minx,miny);
                System.out.println("MAKING LARGE");
               开发者_如何学Go small=false;
            }

                 globalIV.setImageMatrix(mtrx);
            globalIV.setScaleType(ScaleType.MATRIX);
            globalIV.invalidate();

            return false;
        }

Any Ideas?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜