Dear android experts I would like ask you how to make ImageView rotation when moving with it. I have picture of the plane. When I touch_down and moving with it, ImageView follow my finger and also dynamically rotate. When I touch finger up, the plane ImageView rotate up, when I touch left, ImageView rotate dynamically to the left. Please can you show me the way ? I was looking for some examples and was able to work only with a fixed point on the screen, not with a moving object. I was working with examples, such as example Calculate angle of touched point and rotate it in Android . But I have moving objects, can you help ?![picture what I need - dynamiccaly follow finger and rotate it][1]
Asked
Active
Viewed 3,043 times
1 Answers
1
Try this,
public class abc extends Activity implements OnTouchListener
{
ImageView img;
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.one);
img = (ImageView) findViewById(R.id.imageView1);
img.setOnTouchListener(this);
}
public boolean onTouch(View v, MotionEvent event)
{
switch (event.getAction())
{
case MotionEvent.ACTION_DOWN:
{
// Here u can write code which is executed after the user touch on the screen
break;
}
case MotionEvent.ACTION_UP:
{
// Here u can write code which is executed after the user release the touch on the screen
break;
}
case MotionEvent.ACTION_MOVE:
{
// Here u can write code which is executed when user move the finger on the screen
break;
}
}
return true;
}
And also check this link, http://obviam.net/index.php/moving-images-on-the-screen-with-androi/

Randroid
- 3,688
- 5
- 30
- 55
-
Thank you for your answer, But question is how to rotate ImageView around moving path. I am not asking how to make ontouch event. I have moving ImageView and I need rotate it around curve path. Dynamically, angel depends on the situation if I am moving left, right, up, down. – mira Sep 12 '12 at 05:42