简单图片动画播放 android 简单图片动画播放的实例代码

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

简单图片动画播放 android 简单图片动画播放的实例代码

  2021-03-18 我要评论
想了解android 简单图片动画播放的实例代码的相关内容吗,在本文为您仔细讲解简单图片动画播放的相关知识和一些Code实例,欢迎阅读和指正,我们先划重点:图片,动画,播放,下面大家一起来学习吧。

xml中:

复制代码 代码如下:

        <ImageView
            android:id="@+id/touchview"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_centerVertical="true"
            android:src="@drawable/touch" />

java中:
复制代码 代码如下:

               mTouchView = (ImageView) findViewById(R.id.touchview);
                AlphaAnimation mAlphaAnimation = new AlphaAnimation(0.1f, 1.0f); ////创建一个AlphaAnimation对象,参数从透明到不透明

mAlphaAnimation.setDuration(1000);// 设定动画时间
mAlphaAnimation.setRepeatCount(Animation.INFINITE);//定义动画重复时间
mAlphaAnimation.setRepeatMode(Animation.REVERSE);//通过设置重复时间定义动画的行为
mTouchView.setAnimation(mAlphaAnimation);
mAlphaAnimation.start();

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们