开发者

imageview resizing while dragging a image in layout in android

I am creating an android application in which i need to drag imageview. i tried using layout params a开发者_如何学Gond its moving fine but when the image moves nearby right and bottom corner of device then imageview became resizing. i dont know why this happens. my code is below what i tried.

 if (me.getAction() == MotionEvent.ACTION_MOVE) {
                    drag=true;

                    if(drag){
                        int x=(int) (me.getRawX());
                        int y=(int) (me.getRawY());

    innerlayout.setLayoutParams(new RelativeLayout.LayoutParams(innerlayout.getLayoutParams().width, innerlayout.getLayoutParams().height));
                 LayoutParams params = (LayoutParams) innerlayout.getLayoutParams();
                 params.leftMargin = x-25;
                 params.topMargin = y-75;
                innerlayout.setLayoutParams(params);
                                                        }

                }


                else if(me.getAction() == MotionEvent.ACTION_UP)

                {
                    drag=false;


                }
                return true;
            }
        });


look at this Moving Images on the Screen with Android

How to use Multi-touch in Android 2: Part 6, Implementing the Pinch Zoom Gesture

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜