java在it中旋转图像';s位置

java在it中旋转图像';s位置,java,android,graphics,Java,Android,Graphics,我有一个列表视图,每行有一个图标 我希望当我点击行时,图像开始在其自身的中心旋转,就像一个进度条 我已经搜索过了,但我真的对java中的图形一无所知,这就是我所需要的 谢谢假设您这样定义了一个xml文件list\u item.xml: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android

我有一个列表视图,每行有一个图标

我希望当我点击行时,图像开始在其自身的中心旋转,就像一个进度条

我已经搜索过了,但我真的对java中的图形一无所知,这就是我所需要的


谢谢

假设您这样定义了一个xml文件
list\u item.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >
    <ImageView 
       android:id="@+id/image_view"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:src="@drawable/ic_launcher"/>
</LinearLayout>

如果您的图标是位图,则需要一组(至少)7个旋转位置的附加位图(45°、90°、…)。它们看起来就没那么好了。而为这项工作预留场地则需要在两个方向上增加40%。-我不确定这是否是个好主意。眨眼会更容易…谢谢你的帮助,有没有办法让我自己停止旋转?例如,如果我单击按钮或离开活动,它会立即停止旋转?您可以对列表中的所有图像视图应用
imageView.clearAnimation()
,以停止动画。
listview.setOnItemClickListener(new OnItemClickListener() {

    @Override
    public void onItemClick(AdapterView<?> arg0, View view, int arg2,
            long arg3) {
        // TODO Auto-generated method stub
        ImageView imageView = (ImageView) view.findViewById(R.id.image_view);
        Animation rotateAnimation = new       
        RotateAnimation(0f,360f,Animation.RELATIVE_TO_SELF,0.5f,Animation.RELATIVE_TO_SELF,0.5f); 
        rotateAnimation.setInterpolator(new LinearInterpolator());
        rotateAnimation.setRepeatCount(3);
        rotateAnimation.setDuration(3000);              
        imageView.startAnimation(rotateAnimation);        
    }
});