3

我只是想在图像上的特定 (x,y) 位置上设置 uo 标记![在此处输入图像描述][1]

我曾尝试使用位图和画布功能,但直到现在我都没有工作

     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);
4

1 回答 1

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);

}
于 2013-12-21T04:41:51.893 回答