初学Android 图形图像之混合使用逐帧动画和补间动画 三十七

分享一下我老师大神的人工智能教程!零基础,通俗易懂!http://blog.csdn.net/jiangjunshow

也欢迎大家转载本篇文章。分享知识,造福人民,实现我们中华民族伟大复兴!

               

下面例子混合使用了逐帧动画和补间动画,还有一个缺点,就是画面闪烁,一直没有找到解决办法


上面点击ImageView,上面的人物就开始走路跟移动

定义动画文件

<?xml version="1.0" encoding="utf-8"?><animation-list xmlns:android="http://schemas.android.com/apk/res/android" android:oneshot="false">  <item android:drawable="@drawable/one" android:duration="10" />   <item android:drawable="@drawable/two" android:duration="10" />   <item android:drawable="@drawable/three" android:duration="10" />   <item android:drawable="@drawable/four" android:duration="10" />   <item android:drawable="@drawable/five" android:duration="10" />   <item android:drawable="@drawable/six" android:duration="10" />   <item android:drawable="@drawable/seven" android:duration="10" />   <item android:drawable="@drawable/eight" android:duration="10" />   <item android:drawable="@drawable/nine" android:duration="10" />   <item android:drawable="@drawable/ten" android:duration="10" />   <item android:drawable="@drawable/eleven" android:duration="10" />   <item android:drawable="@drawable/twelve" android:duration="10" />   <item android:drawable="@drawable/thirteen" android:duration="10" />   <item android:drawable="@drawable/fourteen" android:duration="10" />   <item android:drawable="@drawable/fifteen" android:duration="10" />   <item android:drawable="@drawable/sixteen" android:duration="10" />   <item android:drawable="@drawable/seventeen" android:duration="10" />   <item android:drawable="@drawable/eighteen" android:duration="10" />   <item android:drawable="@drawable/nineteen" android:duration="10" />   <item android:drawable="@drawable/twenty" android:duration="10" />   <item android:drawable="@drawable/twentyone" android:duration="10" />    <item android:drawable="@drawable/twentytwo" android:duration="10" />   <item android:drawable="@drawable/twentythree" android:duration="10" />   <item android:drawable="@drawable/twentyfour" android:duration="10" />   <item android:drawable="@drawable/twentyfive" android:duration="10" />   <item android:drawable="@drawable/twentysix" android:duration="10" />   <item android:drawable="@drawable/twentyseven" android:duration="10" />   <item android:drawable="@drawable/twentyeight" android:duration="10" />   <item android:drawable="@drawable/twentynine" android:duration="10" />   <item android:drawable="@drawable/thirty" android:duration="10" />   <item android:drawable="@drawable/thirtyone" android:duration="10" />   <item android:drawable="@drawable/thirtytwo" android:duration="10" />   <item android:drawable="@drawable/thirtythree" android:duration="10" />   <item android:drawable="@drawable/thirtyfour" android:duration="10" />   <item android:drawable="@drawable/thirtyfive" android:duration="10" />   <item android:drawable="@drawable/thirtysix" android:duration="10" /> </animation-list>
主界面引用动画

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:id="@+id/layout"    android:layout_width="fill_parent"    android:layout_height="fill_parent"    android:orientation="vertical"     android:background="#fff">    <ImageView android:id="@+id/walk" android:layout_width="150dp"         android:layout_height="150dp"         android:background ="@anim/walk" /> </LinearLayout>

主界面代码

package WangLi.Graphics.Walk;import java.util.Timer;import java.util.TimerTask;import android.app.Activity;import android.graphics.drawable.AnimationDrawable;import android.os.Bundle;import android.os.Handler;import android.os.Message;import android.view.View;import android.view.View.OnClickListener;import android.view.animation.Animation;import android.view.animation.Animation.AnimationListener;import android.view.animation.TranslateAnimation;import android.widget.ImageView;import android.widget.LinearLayout;import android.widget.LinearLayout.LayoutParams;public class Walk extends Activity //记录行走人ImageView当前的位置 private float curX = 0private float curY = 30//记录行走人ImageView下一个位置的坐标  float nextX = 0float nextY = 0;    /** Called when the activity is first created. */    @Override    public void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.main);        //获取显示行走人的ImageView组件        final ImageView imageView = (ImageView)findViewById(R.id.walk);        final Handler handler = new Handler()        {         public void handleMessage(Message msg)         {          if(msg.what == 0x123)          {           //横向上一直向右走           if(nextX > 320)           {            curX = nextX = 0;           }           else           {            nextX += 8;           }                      //纵向上随机上下走           nextY = curY + (float)(Math.random() * 10 - 5);           //设置显示行走人的ImageView位置发生位移改变           TranslateAnimation anim = new TranslateAnimation(curX,             nextX,              curY,              nextY);                      curX = nextX;           curY = nextY;           anim.setDuration(200);           anim.setFillEnabled(true);           //开始位移动画           imageView.startAnimation(anim);          }         }        };        final AnimationDrawable walk = (AnimationDrawable)imageView.getBackground();        imageView.setOnClickListener(new OnClickListener()        {         public void onClick(View v)         {          //开始播放人行走的逐帧动画          walk.start();          //通过定制器控制每0.2秒运行一次TanslateAnimation动画          new Timer().schedule(new TimerTask()          {           public void run()           {            handler.sendEmptyMessage(0x123);           }          }, 0, 200);         }        });    }}



           

给我老师的人工智能教程打call!http://blog.csdn.net/jiangjunshow
这里写图片描述
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
摘 要 伴随着人才教学的关注度越来越高,对于人才的培养也是当今社会发展的最为重要的问题之一。为了进一步的进行人才的培养关工作,许多的学校或者是教育的机构逐步的开展了网络信息化的教学和和管理工作,通过信息化的手段和技术实现网络信息化的教育及管理模式,通过网络信息化的手段实现在线答题在线考试和学生信息在线的管理等操作。这样更加的快捷解决了人才培养之中的问题,也在进一步的促进了网络信息化教学方式的快速的发展工作。相较于之前的人才教育和培养工作之中,存在这许多的问题和局限性。在学生信息管理方面通过线下管理的形式进行学生信息的管理工作,在此过程之中存在着一定的局限性和低效性,往往一些突发的问题导致其中工作出现错误。导致相关的教育工作受到了一定的阻碍。在学生信息和学生成绩的管理方面,往常的教育模式之下都是采用的是人工线下的进行管理和整理工作,在这一过程之中存在这一定的不安全和低效性,面对与学生基数的越来越大,学生的信息管理也在面领着巨大的挑战,管理人员面领着巨大的学生信息的信息量,运用之前的信息管理方式往往会在统计和登记上出现错误的情况的产生,为后续的管理工作造成了一定的困难。然而通过信息化的管理方式进行对学生信息的管理不仅可以避免这些错误情况的产生还可以进一步的简化学生信息管理工作的流程,节约了大量的人力和物力的之处。在线答题系统的实现不仅给学生的信息管理工作和在线考试带来了方便也进一步的促进了教育事业信息化的发展,从而实现高效化的教学工作。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值