尝试重写onTouch
方法,并在其中触摸事件发生的坐标添加图像。
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN){
int x = (int) event.getX() ;
int y = (int) event.getY();
RelativeLayout.LayoutParams lp =new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);; //Assuming you use a RelativeLayout
ImageView iv=new ImageView(getApplicationContext());
lp.setMargins(x,y,0,0);
iv.setLayoutParams(lp);
iv.setImageDrawable(getResources().getDrawable(/*id of your image*/));
((ViewGroup)v).addView(iv);
}
,并确保布局重写onTouch的是RelativeLayout的,充满整个屏幕
你也可以看看在Github以下的项目,它在一定程度上关系到你在找什么。 enter link description here
非常感谢你 –