ImageView currentImage = (ImageView) findViewById(R.id.image) ;
onTouch(View v, MotionEvent event){
if(event.getAction() == MotionEvent.ACTION_DOWN){
float x = event.getX() ;
float y = event.getY();
currentImage.setX(x) ;
currentImage.setY(y) ;
//the 2 lines above must be dragging the image across the screen
}
if( event.getAction() == MotionEvent.ACTION_UP){
currentImage.setX(x) ;
currentImage.setY(y) ;
}
}
However, the code does not work, this is the closest i could come up with.
For anything below Honeycomb (API Level 11) you will have to use
setLayoutParams()
:-If superLayout is RelativeLayout-
If superLayout is Linearlayout-
And If you limit your support to Honeycomb and up you can use the
setX(), setY(), setLeft(), setTop()