软件编程
位置:首页>> 软件编程>> Android编程>> android 简单图片动画播放的实例代码

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

  发布时间:2023-11-07 12:39:01 

标签:图片,动画,播放

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

0
投稿

猜你喜欢

手机版 软件编程 asp之家 www.aspxhome.com