当前位置: 首页 > news >正文

广东外贸网站建设企业手写代码网站

广东外贸网站建设企业,手写代码网站,马鞍山网站开发,阿里云服务器搭网站同时做网盘今天我们就来学习逐帧动画,废话少说直接上效果图如下: 帧动画的实现方式有两种#xff1a; 一、在res/drawable文件夹下新建animation-list的XML实现帧动画 1、首先在res/drawable文件夹下添加img00-img24共25张图片 2、新建frame_anim.xml [html] view plaincopy ?xml v…今天我们就来学习逐帧动画,废话少说直接上效果图如下:     帧动画的实现方式有两种 一、在res/drawable文件夹下新建animation-list的XML实现帧动画 1、首先在res/drawable文件夹下添加img00-img24共25张图片 2、新建frame_anim.xml   [html] view plain copy ?xml version1.0 encodingutf-8?  animation-list xmlns:androidhttp://schemas.android.com/apk/res/android      android:oneshottrue         !-- animation-list 帧动画 --      !-- android:oneshot的值为 false代表播放多次true代表只播放一次 --      !-- duration代表每张图片的播放时间 ,定义一个持续时间为50毫秒的动画帧 --      item          android:drawabledrawable/img00          android:duration50/      item          android:drawabledrawable/img01          android:duration50/      item          android:drawabledrawable/img02          android:duration50/      item          android:drawabledrawable/img03          android:duration50/      item          android:drawabledrawable/img04          android:duration50/      item          android:drawabledrawable/img05          android:duration50/      item          android:drawabledrawable/img06          android:duration50/      item          android:drawabledrawable/img07          android:duration50/      item          android:drawabledrawable/img08          android:duration50/      item          android:drawabledrawable/img09          android:duration50/      item          android:drawabledrawable/img10          android:duration50/      item          android:drawabledrawable/img11          android:duration50/      item          android:drawabledrawable/img12          android:duration50/      item          android:drawabledrawable/img13          android:duration50/      item          android:drawabledrawable/img14          android:duration50/      item          android:drawabledrawable/img15          android:duration50/      item          android:drawabledrawable/img16          android:duration50/      item          android:drawabledrawable/img17          android:duration50/      item          android:drawabledrawable/img18          android:duration50/      item          android:drawabledrawable/img19          android:duration50/      item          android:drawabledrawable/img20          android:duration50/      item          android:drawabledrawable/img21          android:duration50/      item          android:drawabledrawable/img22          android:duration50/      item          android:drawabledrawable/img23          android:duration50/      item          android:drawabledrawable/img24          android:duration50/    /animation-list   3、在activity_main中添加控件     [html] view plain copy RelativeLayout xmlns:androidhttp://schemas.android.com/apk/res/android      xmlns:toolshttp://schemas.android.com/tools      android:layout_widthmatch_parent      android:layout_heightmatch_parent      tools:contextcom.havorld.frameanimation.MainActivity         ImageView          android:idid/imageView          android:layout_widthwrap_content          android:layout_heightwrap_content          android:layout_centerInParenttrue /      !-- android:backgrounddrawable/frame_anim --        LinearLayout          android:layout_widthmatch_parent          android:layout_heightwrap_content          android:layout_alignParentBottomtrue          android:orientationhorizontal          android:padding10dp             Button              android:idid/start              android:layout_width0dp              android:layout_heightwrap_content              android:layout_weight1              android:text播放 /            Button              android:idid/stop              android:layout_width0dp              android:layout_heightwrap_content              android:layout_weight1              android:text停止 /      /LinearLayout    /RelativeLayout   4、在代码中获取并开启帧动画     [java] view plain copy public class MainActivity extends Activity implements OnClickListener {        private ImageView imageView;      private AnimationDrawable animationDrawable;        Override      protected void onCreate(Bundle savedInstanceState) {          super.onCreate(savedInstanceState);          setContentView(R.layout.activity_main);            imageView  (ImageView) findViewById(R.id.imageView);          findViewById(R.id.start).setOnClickListener(this);          findViewById(R.id.stop).setOnClickListener(this);            setXml2FrameAnim1();          // setXml2FrameAnim2();        }        /**      * 通过XML添加帧动画方法一      */      private void setXml2FrameAnim1() {            // 把动画资源设置为imageView的背景,也可直接在XML里面设置          imageView.setBackgroundResource(R.drawable.frame_anim);          animationDrawable  (AnimationDrawable) imageView.getBackground();      }        /**      * 通过XML添加帧动画方法二      */      private void setXml2FrameAnim2() {            // 通过逐帧动画的资源文件获得AnimationDrawable示例          animationDrawable  (AnimationDrawable) getResources().getDrawable(                  R.drawable.frame_anim);          imageView.setBackground(animationDrawable);      }         Override      public void onClick(View v) {            switch (v.getId()) {          case R.id.start:              if (animationDrawable ! null  !animationDrawable.isRunning()) {                  animationDrawable.start();              }              break;          case R.id.stop:              if (animationDrawable ! null  animationDrawable.isRunning()) {                  animationDrawable.stop();              }              break;            default:              break;          }      }    }   二、通过代码实现帧动画     [java] view plain copy /**  * 通过代码添加帧动画方法  */  private void setSrc2FrameAnim() {        animationDrawable  new AnimationDrawable();      // 为AnimationDrawable添加动画帧      animationDrawable.addFrame(              getResources().getDrawable(R.drawable.img00), 50);      animationDrawable.addFrame(              getResources().getDrawable(R.drawable.img01), 50);      animationDrawable.addFrame(              getResources().getDrawable(R.drawable.img02), 50);      animationDrawable.addFrame(              getResources().getDrawable(R.drawable.img03), 50);      animationDrawable.addFrame(              getResources().getDrawable(R.drawable.img04), 50);      animationDrawable.addFrame(              getResources().getDrawable(R.drawable.img05), 50);      animationDrawable.addFrame(              getResources().getDrawable(R.drawable.img06), 50);      animationDrawable.addFrame(              getResources().getDrawable(R.drawable.img07), 50);      animationDrawable.addFrame(              getResources().getDrawable(R.drawable.img08), 50);      animationDrawable.addFrame(              getResources().getDrawable(R.drawable.img09), 50);      animationDrawable.addFrame(              getResources().getDrawable(R.drawable.img10), 50);      animationDrawable.addFrame(              getResources().getDrawable(R.drawable.img11), 50);      animationDrawable.addFrame(              getResources().getDrawable(R.drawable.img12), 50);      animationDrawable.addFrame(              getResources().getDrawable(R.drawable.img13), 50);      animationDrawable.addFrame(              getResources().getDrawable(R.drawable.img14), 50);      animationDrawable.addFrame(              getResources().getDrawable(R.drawable.img15), 50);      animationDrawable.addFrame(              getResources().getDrawable(R.drawable.img16), 50);      animationDrawable.addFrame(              getResources().getDrawable(R.drawable.img17), 50);      animationDrawable.addFrame(              getResources().getDrawable(R.drawable.img18), 50);      animationDrawable.addFrame(              getResources().getDrawable(R.drawable.img19), 50);      animationDrawable.addFrame(              getResources().getDrawable(R.drawable.img20), 50);      animationDrawable.addFrame(              getResources().getDrawable(R.drawable.img21), 50);      animationDrawable.addFrame(              getResources().getDrawable(R.drawable.img22), 50);      animationDrawable.addFrame(              getResources().getDrawable(R.drawable.img23), 50);      animationDrawable.addFrame(              getResources().getDrawable(R.drawable.img24), 50);      // 设置为循环播放      animationDrawable.setOneShot(false);      imageView.setBackground(animationDrawable);  }     点击下载源码  转载于:https://www.cnblogs.com/Im-Victor/p/8760379.html
http://www.pierceye.com/news/176584/

相关文章:

  • 微信网站的链接标志图片如何做公众号如何创建
  • 建站公司建的网站能改动吗怎样设置默认网站
  • 高并发电商网站开发辽宁省朝阳市做网站
  • 公司做网站有用吗合肥企业快速建站
  • 因脉网站建设公司怎么呀韩国网站开发建设技术特点
  • 网站备案 个人 单位安徽网站建设推广
  • 黔江网站制作网站招标建设
  • 网站注册公司目前最好的引流方法
  • 小米wifi设置网址入口网站通信工程建设网站
  • 深圳专业网站建在线做插画的网站
  • 站长之家网站查询怎么样创建自己的小程序
  • 站酷海报设计图片网站备份怎么做
  • 做网站挣钱么云市场 wordpress
  • 网站域名管理规范seo专员是什么
  • 网站制作+资讯网站特色栏目重要性
  • 网站qq 微信分享怎么做的随州市住房和城乡建设部网站
  • 资源网站建设多少钱手机网站页面文字做多大
  • 烟台专业做网站宜昌教育云网站建设
  • 慕课联盟网站开发实战wordpress怎样修改域名
  • 什么电脑做网站前段用旅游网站建设的利益
  • 做 暧视频在线观看网站花都网站建设设计
  • 黄石企业网站设计服务外包有哪些
  • 团队合作网站网站制作的报价大约是多少
  • 网站在线留言系统能挣钱的平台 正规的
  • 冀州网站制作泉州握旗公司网站建设
  • 免费php企业网站苏州网站建设多少钱
  • 重庆网站制作设计抚州网站建设
  • 国外psd网页模板网站免费学校网站管理系统
  • 网站开发合作合同范本电子商务营销渠道有哪些
  • 云南网站建设哪个好沈阳视频制作公司