[英]How to set exactly position another view when zoom or drag (left, right, up, down) image?
I met a big trouble in this case. 在这种情况下,我遇到了很大的麻烦。 I have a imageview (green icon) added on Image background.
我在图像背景上添加了一个imageview(绿色图标)。 Green icon's position is set dynamically(Pic 1)
绿色图标的位置是动态设置的(图片1)
This Image can zoom in, zoom out, drag left, right, up, down. 该图像可以放大,缩小,向左,向右,向上,向下拖动。 I want to to move exactly imageview's position (green icon) when zoom or drag image background.
缩放或拖动图像背景时,我想精确移动imageview的位置(绿色图标)。
How can I map imageview's position (green icon) with Image background when I zoom, drag Image background? 缩放,拖动图像背景时,如何用图像背景映射imageview的位置(绿色图标)?
Picture 2: Image background is zoomed but green icon view does not map with image background, it's wrong position. 图片2:图像背景已放大,但绿色图标视图未与图像背景对应,这是错误的位置。
Can you suggest me some solution, direction or scripts. 您能建议我一些解决方案,方向或脚本吗? Thanks all!
谢谢大家!
use following function which will overlay your image bitmap with mark image bitmap and return new bitmap which you can use to display 使用以下功能,该功能将用标记图像位图覆盖您的图像位图并返回可用于显示的新位图
private Bitmap overlay(Bitmap bmp1, Bitmap bmp2, float left, float top) {
Bitmap bmOverlay = Bitmap.createBitmap(bmp1.getWidth(), bmp1.getHeight(), bmp1.getConfig());
Canvas canvas = new Canvas(bmOverlay);
canvas.drawBitmap(bmp1, new Matrix(), null);
canvas.drawBitmap(bmp2, left, top, null);
return bmOverlay;
}
eg :- 例如:-
Bitmap border = null;
Bitmap scaledBorder = null;
border = BitmapFactory.decodeResource(getResources(), R.drawable.palette);
scaledBorder = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);
ImageView im = (ImageView) findViewById(R.id.imageView);
im.setImageBitmap(overlay(border, scaledBorder, 0, 0));// replace both 0,0 point with your mark point
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.