亲爱的android专家我想问你如何在移动时让ImageView旋转。我有飞机的照片。当我 touch_down 并随之移动时,ImageView 会跟随我的手指并动态旋转。当我手指向上触摸时,ImageView 平面向上旋转,当我向左触摸时,ImageView 动态向左旋转。请你给我指路好吗?我正在寻找一些示例,并且只能使用屏幕上的固定点,而不是移动对象。我正在使用示例,例如示例计算触摸点的角度并在 Android 中旋转它。但是我有移动的物体,你能帮忙吗?![画出我需要的东西 - 动态跟随手指并旋转它][1]
问问题
3022 次
1 回答
1
尝试这个,
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;
}
并检查此链接, http: //obviam.net/index.php/moving-images-on-the-screen-with-androi/
于 2012-09-12T05:12:05.753 回答