Place image at coordinates Android

后端 未结 3 1647
一整个雨季
一整个雨季 2020-12-15 12:34

I have a program in which I would like to place an image at the coordinates of a touch event. I have the coordinates now I just need help with placing an image there. I will

3条回答
  •  自闭症患者
    2020-12-15 13:08

    Drawable recycle_bin = context.getResources().getDrawable(android.R.drawable.ic_menu_delete);
    int w = recycle_bin.getIntrinsicWidth();
    int h = recycle_bin.getIntrinsicHeight();
    int x = getWidth()/2 - w/2;
    int y = getHeight() - h - 5;
    
    recycle_bin.setBounds( x, y, x + w, y + h );
    recycle_bin.draw( canvas );
    

    that's how I draw a recycle bin icon at the bottom center

提交回复
热议问题