android 简单图片动画播放的实例代码
android 简单图片动画播放的实例代码
发布时间:2016-12-28 来源:查字典编辑
摘要:xml中:复制代码代码如下:java中:复制代码代码如下:mTouchView=(ImageView)findViewById(R.id.t...

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();

推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
相关阅读
网友关注
最新安卓软件开发学习
热门安卓软件开发学习
编程开发子分类