2

I use the code below to display an image in the screen.

ImageView img = (ImageView) findViewById(R.id.imageView1);
    img.setImageResource(R.drawable.car);

I want to let the user, to reposition it by finger to any place. which one I can use?

  1. setOnTouchListener
  2. onDrag

This is when I have two cars. and the background is another bitmap image.

jonsca
  • 10,218
  • 26
  • 54
  • 62
John_sei4
  • 103
  • 2
  • 8
  • You can use both but it depend upon your requisite like what you what ie you just want to re position your image where ever user touches on screen or else you want to longpress it and then drop where user the touch movement end ............. for Ist case go these http://stackoverflow.com/questions/1660150/move-imageview-around-inside-relativelayout – Vipin Sahu Sep 25 '12 at 19:32

3 Answers3

0

You can do so. But its a bit complicated. Have a look at this great tutorial:

http://blahti.wordpress.com/2011/01/17/moving-views-part-2/

Givi
  • 3,283
  • 4
  • 20
  • 23
0

You can use both but it depend upon your requisite like what you what ie you just want to re position your image where ever user touches on screen or else you want to longpress it and then drop where user the touch movement end ............. for Ist case go these Move ImageView around inside RelativeLayout and for second case use these Drag and drop images in android

Community
  • 1
  • 1
Vipin Sahu
  • 1,441
  • 1
  • 18
  • 29
0

To change the image position by finger in java android you will need to work with

Surface View and onTouchListener both of them have described precisely in Android Developer Site.

You also can check this question from which you will get help

Touch and drag image in android

Happy Coding.

Community
  • 1
  • 1
Siddiq Abu Bakkar
  • 1,949
  • 1
  • 13
  • 24