随笔 - 13,  文章 - 0,  评论 - 0,  阅读 - 3984
< 2025年4月 >
30 31 1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 1 2 3
4 5 6 7 8 9 10

android支持三种类型的动画:

·属性动画  一种补间动画,通过在目标对象的任何属性的两个值之间应用赠了变化,可以生成一种动画效果。这种动画可以用来生成各种效果,例如:改变视图的颜色、透明条、淡入淡出、改变字体大小或者增加字符的生命力。

·视图动画  一种补间动画,可以用来旋转、缩放和拉伸一个视图。

·帧动画    逐帧的格子动画,来显示一系列的drawable图片。

 

属性动画示例:1秒内以增量的方式在0和1之间调用目标对象的setAlpha方法,从而改变目标对象的透明度。

xml文件存放位置res/animator 文件夹下

<?xml version="1.0" encoding="utf-8"?>
<objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"
    android:propertyName="alpha"
    android:duration="1000"
    android:valueFrom="0.0"
    android:valueTo="1.0">
    
</objectAnimator>

 

调用方法:

   private ImageView img;

img=(ImageView)this.findViewById(R.id.imageView1); Animator animator
=AnimatorInflater.loadAnimator(this, R.animator.alpha); animator.setTarget(img); animator.start();

 

 

视图动画示例:目标在旋转360°的同时收缩并淡出。

xml文件存放位置 res/anim

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
    android:interpolator="@android:anim/accelerate_interpolator" >

    <rotate
        android:duration="1000"
        android:fromDegrees="0"
        android:pivotX="50%"
        android:pivotY="50%"
        android:startOffset="500"
        android:toDegrees="360" />

    <scale
        android:duration="500"
        android:fromXScale="1.0"
        android:fromYScale="1.0"
        android:pivotX="50%"
        android:pivotY="50%"
        android:startOffset="500"
        android:toXScale="0.0"
        android:toYScale="0.0" />

    <alpha
        android:duration="500"
        android:fromAlpha="1.0"
        android:startOffset="500"
        android:toAlpha="0.0" />

</set>

 

 调用方法:

    Animation anim=AnimationUtils.loadAnimation(this, R.anim.amin_scoal);
    img.setAnimation(anim);
    img.animate().start();

 

动画类型属性
动画类型 效果 属性 有效值
Alpha 淡入/淡出 fromAlpha/toAlpha 0~1的浮点数
Scale 缩放 fromXScale/toXScale 0~1的浮点数
fromYScale/toYScale 0~1的浮点数
pivotX/pivotY 表示图像的宽/高比的字符串,从0%~100%
translate 移动 fromX/toX 0~1的浮点数
fromY/toY 0~1的浮点数
Rotate 旋转 fromDegrees/toDegrees 0~360的浮点数
pivotX/pivotY 表示图像的宽/高比的字符串,从0%~100%

   ·duration 动画的持续时间,已毫秒为单位。

   ·startOffset 动画开始之前的延迟,毫秒为单位

   ·fillBeforetrue 在动画开始之前动画变形。

   ·fillAftertrue 在动画开始只有变形

   ·interpolator 设置效果随时间改变的速度

 

<scale>标签为缩放节点
android:fromXscale="1.0" 表示开始时X轴缩放比例为 1.0 (原图大小 * 1.0 为原图大小)
android:toXscale="0.0"表示结束时X轴缩放比例为0.0(原图大小 *0.0 为缩小到看不见)
android:fromYscale="1.0" 表示开始时Y轴缩放比例为 1.0 (原图大小 * 1.0 为原图大小)
android:toYscale="0.0"表示结束时Y轴缩放比例为0.0(原图大小 *0.0 为缩小的看不到了)
android:pivotX="50%" X轴缩放的位置为中心点
android:pivotY="50%" Y轴缩放的位置为中心点
android:duration="2000" 动画播放时间 这里是2000毫秒也就是2秒

 

逐帧动画示例:循环显示一系列位图资源,每个资源会持续半秒。

xml文件存放位置res/drawable   

<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
    android:oneshot="false">
  <item android:drawable="@drawable/test1" android:duration="500"></item>
  <item android:drawable="@drawable/test2" android:duration="500"></item>
  <item android:drawable="@drawable/test3" android:duration="500"></item>
</animation-list>

 调用方法:

ImageView view=new ImageView(this);

view.setBackgroundResource(R.drawable.animtion_d);

AnimationDrawable anim=(AnimationDrawable)view.getBackground();

anim.start();

 

posted @ 2015-02-10 15:41 Object 罗 阅读(217) 评论(0) 推荐(0) 编辑
摘要: http://niufc.iteye.com/blog/1729792 阅读全文
posted @ 2014-08-25 15:55 Object 罗 阅读(805) 评论(0) 推荐(0) 编辑
只有注册用户登录后才能阅读该文。 阅读全文
posted @ 2014-08-08 15:30 Object 罗 阅读(1) 评论(0) 推荐(0) 编辑
摘要: http://tech.ddvip.com/2013-09/1379785198203013_2.html 阅读全文
posted @ 2014-07-31 17:00 Object 罗 阅读(145) 评论(0) 推荐(0) 编辑
摘要: cmd 进去keystore 文件所在目录 keytool -list -v -keystore xxx.keystoredebug.keystore 默认目录:C:\Documents and Settings\Administrator\.android 阅读全文
posted @ 2014-04-26 14:14 Object 罗 阅读(659) 评论(0) 推荐(0) 编辑
摘要: cmd 进入jdk下的bin目录(我的目录:C:\Program Files\Java\jdk1.6.0_37\bin)keytool-genkey-aliasxxx.keystore-keyalgRSA-validity20000-keystorexxx.keystore根据提示填写信息 完成后x... 阅读全文
posted @ 2014-04-26 14:10 Object 罗 阅读(220) 评论(0) 推荐(0) 编辑
摘要: pd = ProgressDialog.show(getActivity(), "请稍候..", "正在收集软件信息...", true,false); Thread thread = new Thread(this); thread.start(); @Override public void run() { if(mlistAppInfo==null){ mlistAppInfo = new ArrayList(); queryAppInfo(); ... 阅读全文
posted @ 2014-02-27 15:24 Object 罗 阅读(547) 评论(0) 推荐(0) 编辑
摘要: 开发实战_安卓Android开发入门、进阶、高级教程 - eoeAndroid社区-Android开发者的必备网站-全球最大中文Android开发社区-eoe移动开发社区 http://training.eoeandroid.com/#Starting_an_Activity 阅读全文
posted @ 2013-06-18 15:52 Object 罗 阅读(286) 评论(0) 推荐(0) 编辑
摘要: <span class="f_right"><a href="javascript:void(0);" class="hulve" tags="<%=123 %>">忽略</a></span>通过class绑定$(".hulve").click(function(){ //alert($(this).attr("tags")); var html =$(this).parent(); var id = $(this) 阅读全文
posted @ 2013-06-04 17:22 Object 罗 阅读(164) 评论(0) 推荐(0) 编辑
摘要: 1 class ChinaIndex 2 { 3 4 // string indexXmlPath = Assembly.GetExecutingAssembly().Location + "\\index.xml"; 5 6 private string activityIndexId = "0", lineIndexId = "0", poiIndexId = "0", journeyIndexId = "0", memberIndexId = "0", companyI 阅读全文
posted @ 2013-05-28 10:03 Object 罗 阅读(240) 评论(0) 推荐(0) 编辑
点击右上角即可分享
微信分享提示