龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > 移动开发 > Android开发 >

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

时间:2014-06-16 15:43来源:网络整理 作者:网络 点击:
分享到:
android 简单图片动画播放的实例代码,需要的朋友可以参考一下

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

精彩图集

赞助商链接