简体   繁体   English

animation 在 android 上旋转图像

[英]animation of rotating an image on android

I have doubts on how to make an image rotate like this:我对如何使图像像这样旋转有疑问:

Expected animation预计animation

used icon使用过的图标

I looked in some forums, and what I found helped me get to this point:我查看了一些论坛,发现的内容帮助我达到了这一点:

what i got我得到了什么

Drawable



<?xml version="1.0" encoding="utf-8"?>
    <animated-rotate xmlns:android="http://schemas.android.com/apk/res/android"
        android:fromDegrees="0"
        android:pivotX="50%"
        android:pivotY="50%"
        android:toDegrees="360"
        android:repeatCount="infinite"
        android:drawable="@drawable/image" >
    </animated-rotate>

Can someone help me?有人能帮我吗?

Thank you!!谢谢!!

Make anim folder then create rotate xml file制作动画文件夹然后创建旋转 xml 文件

<?xml version="1.0" encoding="utf-8"?><set xmlns:android="http://schemas.android.com/apk/res/android"><rotate
    android:duration="1500"
    android:fromDegrees="0"
    android:pivotX="50%"
    android:pivotY="50%"
    android:toDegrees="720" /></set>

Apply on Image应用于图像

 final ImageView rotate = (ImageView) findViewById(R.id.lolo);
    final Animation rotateAnimation = AnimationUtils.loadAnimation(this, R.anim.rotate);
    rotate.startAnimation(rotateAnimation);

I managed to solve the problem.我设法解决了这个问题。 Resolution below.决议如下。

Animation a = new RotateAnimation(0.0f, 360.0f,
            Animation.RELATIVE_TO_SELF, 0.34f, Animation.RELATIVE_TO_SELF,
            0.67f);
    this.startAnimation(a);
    a.setRepeatCount(-1);
    a.setDuration(680);

Xml Xml

    <LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center">

    <Imageview
        android:layout_width="35dp"
        android:layout_height="35dp"
        app:typeSpinner="default-spinner" />

</LinearLayout>

Result结果

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM