温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

android运用旋转动画

发布时间:2020-07-13 19:48:07 来源:网络 阅读:472 作者:文dan 栏目:移动开发

Android 平台提供了两类动画,一类是 Tween 动画,即通过对场景里的对象不断做图像变换(平移、缩放、旋转)产生动画效果;第二类是 Frame 动画,即顺序播放事先做好的图像。本文分析 Tween动画的rotate实现旋转效果。下面直接给出代码,并且附近中有完整的demo,具体不多说,直接上代码,附近中有项目demo可供下载。


主类:

public class MainActivity extends ActionBarActivity {
    private ImageView infoOperatingIV;

    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        infoOperatingIV = (ImageView)findViewById(R.id.infoOperating);  //图片对象实例化
        Animation operatingAnim = AnimationUtils.loadAnimation(this, R.anim.tip);  //创建动画对象并实例化,tip为动画的文件
        LinearInterpolator lin = new LinearInterpolator();  
        
        operatingAnim.setInterpolator(lin);

        if (operatingAnim != null) {  
            infoOperatingIV.startAnimation(operatingAnim);  
        }  

    }


布局 activity_main.xml



<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="center"
    android:gravity="center"
    tools:context="com.example.testanimation.MainActivity" >
 
<ImageView  
        android:id="@+id/infobg"  
        android:layout_width="200dp"  
        android:layout_height="200dp"  
        android:src="@drawable/cemung_out_roate"  
       />  
     <ImageView  
        android:id="@+id/infoOperating"  
        android:layout_width="200dp"  
        android:layout_height="200dp"  
        android:src="@drawable/cemung_in_roate"  
        />  
        

</RelativeLayout>

动画 tip.xml

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

实例中的图片放在


图片:cemung_in_roate

android运用旋转动画图片:  cemung_out_roate

android运用旋转动画

效果截图

中间的×××圆圈转动

android运用旋转动画



附件:http://down.51cto.com/data/2366188
向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI