Android画布图像缩放

Android画布图像缩放,android,canvas,android-image,Android,Canvas,Android Image,我是android开发的新手,目前正在开发一个应用程序,该应用程序正在画布和图像上工作。。。 但我被困在这个过程的中间 我想实现这样一个功能,用户触摸图像的边缘,如果他/她拖动图像,图像将被缩放 我在谷歌上搜索了很多,但找不到任何教程或演示 希望你们能帮助我。这样的功能由galaxy Note提供,如下图所示 试试这个 如果用户触摸右侧的图像并拖动右侧,则下面的代码将缩放图像并绘制缩放图像 Bitmap bmpImage; Rect src = new Rect();

我是android开发的新手,目前正在开发一个应用程序,该应用程序正在画布和图像上工作。。。 但我被困在这个过程的中间

我想实现这样一个功能,用户触摸图像的边缘,如果他/她拖动图像,图像将被缩放

我在谷歌上搜索了很多,但找不到任何教程或演示

希望你们能帮助我。这样的功能由galaxy Note提供,如下图所示

试试这个

如果用户触摸右侧的图像并拖动右侧,则下面的代码将缩放图像并绘制缩放图像

Bitmap bmpImage;
        Rect src = new Rect();
        Rect dst = new Rect();
        src.left = initial_Start_pos_X;  // initial Start X postion of image
        src.top = initial_Start_pos_Y;   // initial Start Y postion of image
        src.right =initial_End_pos_X;  // initial End X postion of image
        src.bottom = initial_End_pos_Y;  // initial End Y postion of image

        dst.left = initial_Start_pos_X;
        dst.top = initial_Start_pos_Y;
        dst.right = Draged_Pox_X;       // Drag X position of image
        dst.bottom = initial_End_pos_Y;

        canvas.drawBitmap(bmpImage, src, dst, paint); // This line will scaled the image according to dst rect. It will take the image from src rect and draw in dst rect. so it will scaled the image.
每次拖动图像一侧时,都必须使视图无效。您必须在ONTOUCHMOVE中使视图无效

因此,您必须首先检查,用户是否触摸并拖动图像的哪一侧,然后您必须修改上述代码。 以上代码仅在右侧显示缩放图像