android运用旋转动画-创新互联

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

另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。

当前标题:android运用旋转动画-创新互联
网页路径:https://www.cdcxhl.com/article4/copcie.html

成都网站建设公司_创新互联,为您提供用户体验网站改版网站维护面包屑导航网站排名定制网站

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联

搜索引擎优化