Android开发之自定义动画

<h1>Android开发之自定义动画</h1>
/*

* Android开发之动画

* 北京Android俱乐部群:167839253

* Created on: 2011-8-23

* Author: blueeagle

* Email: liujiaxiang@gmail.com

*/

总结一下关于Android开发下的自定义动画,主要是四个方面,尺寸,透明度,位置变化和旋转。动画需要写在res的anim目录下。写完直接调用就可以了。

如下所示动画文件:

<textarea readonly name="code" class="html"><?xml version="1.0" encoding="utf-8"?>

<set xmlns:android="http://schemas.android.com/apk/res/android">

<translate android:interpolator="@android:anim/accelerate_decelerate_interpolator"

android:fromYDelta="-100"

android:toYDelta="0"

android:duration="1000"

android:fillEnabled="true"

android:fillAfter="true"

/>

<scale android:fromXScale="0.6" android:toXScale="1.0"

android:fromYScale="0.6" android:toYScale="1.0" android:pivotX="50%"

android:pivotY="50%" android:duration="2000" />

<alpha android:interpolator="@android:anim/decelerate_interpolator"

android:fromAlpha="0.0" android:toAlpha="1.0" android:duration="2000" />



<rotate

android:interpolator="@android:anim/accelerate_decelerate_interpolator"

android:fromDegrees="0"

android:toDegrees="+359"

android:pivotX="50%"

android:pivotY="50%"

android:duration="2000">

</rotate>

</set>

</textarea><br>

相应说明:


fromAlpha为动画起始时的透明度;

toAlpha为动画结束时的透明度;

interpolator为制定一个动画的插入器;

fromXScale为动画起始时x坐标上的伸缩尺寸;

toXScale为动画结束时x坐标上的伸缩尺寸;

fromYScale为动画起始时y坐标上的伸缩尺寸;

toYScale为动画结束时y坐标上的伸缩尺寸;

pivotX和pivotY设置动画相对于自身的位置;

fillAfter表示动画的转换在动画结束后是否被应用;

fromDegrees为动画起始时物件的角度;

toDegrees为动画结束时物件旋转的角度。


在Android开发之popwindow中已经讲过了对于弹出框动画的使用方法。现在记录一下图片动画的开发方法。



只需要三行代码就可以加载图片动画:


<p align="left"> myImageView = (ImageView)findViewById(R.id.[i]myImageView[/i]);
myImageView.startAnimation(myAnimation);

需要在xml布局文件中加载图片:

<textarea readonly name="code" class="html"> <ImageView

android:id="@+id/myImageView"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:src="@drawable/icon"

/>
</textarea><br>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值