Android ApiDemo 分析(一)
来源:互联网 发布:淘宝 欧服月卡 编辑:程序博客网 时间:2024/06/08 02:10
一直想系统学习一下Android 的API Demo中的实例,开始第一个!(该ApiDemo基于Android2.2--version 8)
先从显示部分入手
app/activity/anmation这个demo主要展示的是activity的动画效果,定义了两种效果,fade(淡入淡出)、zoom(由大变小),用button监听产生变化。
android的animation有四种基本动画alpha(透明度渐变)、translate(平移)、scale(缩放)、rotate(旋转)。
它们都可以在xml中定义,也可以使用java代码实现。demo中使用的是xml定义
所有的动画效果都放在res/anim下,(anim是约定的文件夹名,应该也可以使用其他的名称,没试过。。。)
在xml中使用<set>标签可以定义4种动画的组合,否则一个xml文件只能定义其中的一种。
animation有一些共同的属性
android:duration动画执行时间
android:fillAfter动画执行后,控件将停留在执行结束的状态
android:fillBefore动画执行后,控件将回到执行前的状态
android:startOffSet设置动画执行前的等待时间
android:repeatCount设置重复执行次数
android:repeatMode设置重复行为 (restart重新开始、reverse反向开始)
android:zAdjustment(暂时不明。。。)
特有属性
<alph
android:fromAlpha 透明度从0.0到1.0
android:toAlpha
/>
<translate
android:fromXDelta X轴起点
android:toXDelta X轴终点
android:fromYDelta Y轴起点
android:toYDelta Y轴终点
//这里设置的值有三种 1、绝对值(如50)2、相对控件本身(如50%)3、相对父控件(如50%p)
/>
<rotate
android:fromDegrees 设置角度(-360到360)
android:toDegrees
android:pivotX 设置旋转圆心坐标,也由3种值 同translate
android:pivotY
/>
<scale
android:fromXScale X方向起始大小,float,小于1表示缩小,大于1表示放大
android:toXScale X反向结束大小
android:fromYScale Y方向起始大小
android:toYScale Y方向结束大小
android:pivotX 缩放中心点x坐标
android:pivotY 缩放中心点Y坐标
1、代码中加载xml动画AnimationUtils.loadAnimation(context, xml);
2、Interpolator插值器
插值器用于定义动画播放过程中速度的变化,一共有以下几种插值器
(1)AcceleratorInterpolator 加速器
(2)DecelerateInterpolator,减速器
(3)AccelerateDecelerateInterpolator, 先加速再减速
(4)LinearInterpolator, 匀速
(5)AnticipateInterpolator, 超前,会在动画开始是向前移动一段距离
(6)OvershootInterpolator,惯性,会在动画结束前超出预设的值,比如要从1移动到5,这个插值器会产生1->6->5的效果
(7)AnticipateOvershootInterpolator,(5)与(6)的结合体
(8) BounceInterpolator, 弹性,就像橡胶球落地的效果,
(9)CycleInterpolator, 循环,可以设定循环次数
各个插值器的一些具体的属性设置
<declare-styleable name="AccelerateInterpolator"> <!-- This is the amount of deceleration to add when easing in. --> <attr name="factor" format="float" /> </declare-styleable> <declare-styleable name="DecelerateInterpolator"> <!-- This is the amount of acceleration to add when easing out. --> <attr name="factor" /> </declare-styleable> <declare-styleable name="CycleInterpolator"> <attr name="cycles" format="float" /> </declare-styleable> <declare-styleable name="AnticipateInterpolator"> <!-- This is the amount of tension. --> <attr name="tension" format="float" /> </declare-styleable> <declare-styleable name="OvershootInterpolator"> <!-- This is the amount of tension. --> <attr name="tension" /> </declare-styleable> <declare-styleable name="AnticipateOvershootInterpolator"> <!-- This is the amount of tension. --> <attr name="tension" /> <!-- This is the amount by which to multiply the tension. --> <attr name="extraTension" format="float" /> </declare-styleable>
- Android ApiDemo 分析(一)
- Android ApiDemo 分析(二)
- Android ApiDemo分析(三)
- Android ApiDemo分析(四)
- Android ApiDemo分析(五)
- Android ApiDemo分析(六)
- Android ApiDemo分析(七)
- Android ApiDemo分析(八)
- Android ApiDemo分析(九)--Graphics
- android ApiDemo学习(一)service总结
- APIDemo Service(一)
- Android APIDemo 中蓝牙分析
- Android ApiDemo分析(十)—— ListView的用法
- Android ApiDemo 笔记(一)Content与Graphics
- Android ApiDemo 笔记(一)Content与Graphics
- Android ApiDemo 笔记(一)Content与Graphics
- Android ApiDemo 笔记(一)Content与Graphics
- Android ApiDemo(十二)-- Graphics2
- php coding中的一些小问题
- 车牌识别C语言源码 第一版
- vs2005奇怪的断点无效问题
- 通过Socket进行HttP/HTTPS网页操作
- 为什么系统调用消耗更多时间?
- Android ApiDemo 分析(一)
- 空舰导弹发展历程(摘自兵器知识)
- C#基础学习之二 文件读取 denuvead
- 博文代码索引
- 浅谈objective-C中的description方法
- 解放军报评论:失却精神的民族只能任人宰割
- 嵌入式空间数据库研究
- android自定义控件实现
- 用计算机的随机数做成的图像(灰度和彩色