Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/186.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 图像旋转_Android_Rotation_Imageview - Fatal编程技术网

Android 图像旋转

Android 图像旋转,android,rotation,imageview,Android,Rotation,Imageview,我在安卓上工作。我想创建一个旋转图像并选择其中的部分。例如,如果图像是人头,则在其旋转时,可以选择耳朵。现在我做了图像部分选择,但我不知道如何旋转它?有人能给我一个简单的方法吗?你应该使用类来制作动画,并为你的视图设置动画你有两种方法来旋转图像,我用xml简单地说 首先在目录res中创建一个名为anim 在目录anim中,使用以下代码创建文件xml: <?xml version="1.0" encoding="utf-8"?> <rotate xmlns:android="ht

我在安卓上工作。我想创建一个旋转图像并选择其中的部分。例如,如果图像是人头,则在其旋转时,可以选择耳朵。现在我做了图像部分选择,但我不知道如何旋转它?有人能给我一个简单的方法吗?

你应该使用类来制作动画,并为你的视图设置动画

你有两种方法来旋转图像,我用xml简单地说

首先在目录
res
中创建一个名为
anim

在目录
anim
中,使用以下代码创建文件xml:

<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android" 
    android:fromDegrees="0"
    android:toDegrees="360"
    android:pivotX="50%"
    android:pivotY="50%"
    android:duration="1000"
    >    
</rotate>
非常感谢:)如果我想在旋转时更改图像怎么办。我的意思是,当它从左向右旋转时,大脑的另一侧就来了@约塞德卢扬
public class MainActivity extends Activity implements OnClickListener{
    ImageView imagen; //declare the image will use
    Button boton; // this button will activie de rotation
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        imagen = (ImageView) findViewById(R.id.iv);
        boton = (Button)findViewById(R.id.bt);

        boton.setOnClickListener(this); 

    }
    @Override
    public void onClick(View v) {
        // TODO Auto-generated method stub
        switch (v.getId()) {
        case R.id.bt:
            Animation rotacion; // declare an animation
            rotacion  = AnimationUtils.loadAnimation(this,R.anim.rotar);

            rotacion.reset();
            imagen.startAnimation(rotacion);

            break;

        default:
            break;
        }

    }