我正在尝试在图像上的特定(x,y)位置设置uo标记![在此处输入图像描述] [1]
我曾尝试使用Bitmap和canvas函数,但直到现在我都没有工作
Bitmap viewBitmap = Bitmap.createBitmap(image.getWidth(),image.getHeight(),Bitmap.Config.ALPHA_8);//i is imageview which u want to convert in bitmap
Canvas canvas = new Canvas(viewBitmap);
Paint paint = new Paint(2222);
viewBitmap.extractAlpha();
viewBitmap.eraseColor(getWallpaperDesiredMinimumHeight());
viewBitmap = viewBitmap.extractAlpha(paint, null);
canvas.drawBitmap(viewBitmap, 10, 10,paint);
canvas.drawCircle(20, 20, 5, paint);
canvas.clipRect(10,10, 10, 10);
image.draw(canvas);
答案 0 :(得分:0)
你可以用这个
@Override
public boolean onTouch(View view, MotionEvent event) {
float eventX = event.getX();
float eventY = event.getY();
int x1=(int)eventX;
int y1=(int)eventY;
setLocation(x1, y1);
return false;
}
public void setLocation(int x, int y) {
final LinearLayout iv = (LinearLayout) findViewById(R.id.tag_relay);
final AbsoluteLayout.LayoutParams lp = (AbsoluteLayout.LayoutParams) iv.getLayoutParams();
lp.x = x;
lp.y = y;
iv.setLayoutParams(lp);
// iv.setVisibility(View.VISIBLE);
}