上一篇文章中我们分析了属性动画的工作原理,这篇文章开始介绍属性动画的实现,就不会再去分析原理,如果对原理不清楚的朋友可以看一下 Android属性动画-Property Animation(一) 原理分析
使用属性动画时我们通常使用Animator的两个子类,ValueAnimator和ObjectAnimator。这两个子类如何选择呢?在大多数情况下我们会使用ObjectAnimator,它比较轻量级,使用非常简单,但是它也有一些局限性,就是必须要实现属性的getter和setter方法,因为使用ValueAnimator的时候我们必须实现ValueAnimator.AnimatorUpdateListener接口,并且在onAnimationUpdate()里面手动更新属性值,而ObjectAnimator不用,那么他就必须要通过setter方法自动给属性赋值,getter方法自动获得属性的值。
因为ObjectAnimator使用的比较多,使用起来又比较简单,我们就先来分析一下ObjectAnimator怎么使用吧
其实ObjectAnimator是ValueAnimator的一个子类,既然google这样设计,那么它肯定进行了某方面的优化,我们上面已经提到了,使用ObjectAnimator不用再去实现ValueAnimator.AnimatorUpdateListener接口了,因为他会自动去更新属性值。
我们先来看一个简单的例子:
<a target=_blank id="L1" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L1" rel="#L1" style="color: rgb(102, 102, 102); text-decoration: none;"> 1</a> <a target=_blank id="L2" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L2" rel="#L2" style="color: rgb(102, 102, 102); text-decoration: none;"> 2</a> <a target=_blank id="L3" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L3" rel="#L3" style="color: rgb(102, 102, 102); text-decoration: none;"> 3</a> <a target=_blank id="L4" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L4" rel="#L4" style="color: rgb(102, 102, 102); text-decoration: none;"> 4</a> <a target=_blank id="L5" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L5" rel="#L5" style="color: rgb(102, 102, 102); text-decoration: none;"> 5</a> <a target=_blank id="L6" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L6" rel="#L6" style="color: rgb(102, 102, 102); text-decoration: none;"> 6</a> <a target=_blank id="L7" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L7" rel="#L7" style="color: rgb(102, 102, 102); text-decoration: none;"> 7</a> <a target=_blank id="L8" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L8" rel="#L8" style="color: rgb(102, 102, 102); text-decoration: none;"> 8</a> <a target=_blank id="L9" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L9" rel="#L9" style="color: rgb(102, 102, 102); text-decoration: none;"> 9</a> <a target=_blank id="L10" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L10" rel="#L10" style="color: rgb(102, 102, 102); text-decoration: none;"> 10</a> <a target=_blank id="L11" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L11" rel="#L11" style="color: rgb(102, 102, 102); text-decoration: none;"> 11</a> <a target=_blank id="L12" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L12" rel="#L12" style="color: rgb(102, 102, 102); text-decoration: none;"> 12</a> <a target=_blank id="L13" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L13" rel="#L13" style="color: rgb(102, 102, 102); text-decoration: none;"> 13</a> <a target=_blank id="L14" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L14" rel="#L14" style="color: rgb(102, 102, 102); text-decoration: none;"> 14</a> <a target=_blank id="L15" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L15" rel="#L15" style="color: rgb(102, 102, 102); text-decoration: none;"> 15</a> <a target=_blank id="L16" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L16" rel="#L16" style="color: rgb(102, 102, 102); text-decoration: none;"> 16</a> <a target=_blank id="L17" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L17" rel="#L17" style="color: rgb(102, 102, 102); text-decoration: none;"> 17</a> <a target=_blank id="L18" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L18" rel="#L18" style="color: rgb(102, 102, 102); text-decoration: none;"> 18</a> <a target=_blank id="L19" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L19" rel="#L19" style="color: rgb(102, 102, 102); text-decoration: none;"> 19</a> <a target=_blank id="L20" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L20" rel="#L20" style="color: rgb(102, 102, 102); text-decoration: none;"> 20</a> <a target=_blank id="L21" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L21" rel="#L21" style="color: rgb(102, 102, 102); text-decoration: none;"> 21</a> <a target=_blank id="L22" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L22" rel="#L22" style="color: rgb(102, 102, 102); text-decoration: none;"> 22</a> <a target=_blank id="L23" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L23" rel="#L23" style="color: rgb(102, 102, 102); text-decoration: none;"> 23</a> <a target=_blank id="L24" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L24" rel="#L24" style="color: rgb(102, 102, 102); text-decoration: none;"> 24</a> <a target=_blank id="L25" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L25" rel="#L25" style="color: rgb(102, 102, 102); text-decoration: none;"> 25</a> <a target=_blank id="L26" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L26" rel="#L26" style="color: rgb(102, 102, 102); text-decoration: none;"> 26</a> <a target=_blank id="L27" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L27" rel="#L27" style="color: rgb(102, 102, 102); text-decoration: none;"> 27</a> <a target=_blank id="L28" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L28" rel="#L28" style="color: rgb(102, 102, 102); text-decoration: none;"> 28</a> <a target=_blank id="L29" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L29" rel="#L29" style="color: rgb(102, 102, 102); text-decoration: none;"> 29</a> <a target=_blank id="L30" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L30" rel="#L30" style="color: rgb(102, 102, 102); text-decoration: none;"> 30</a> <a target=_blank id="L31" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L31" rel="#L31" style="color: rgb(102, 102, 102); text-decoration: none;"> 31</a> <a target=_blank id="L32" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L32" rel="#L32" style="color: rgb(102, 102, 102); text-decoration: none;"> 32</a> <a target=_blank id="L33" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L33" rel="#L33" style="color: rgb(102, 102, 102); text-decoration: none;"> 33</a> <a target=_blank id="L34" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L34" rel="#L34" style="color: rgb(102, 102, 102); text-decoration: none;"> 34</a> <a target=_blank id="L35" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L35" rel="#L35" style="color: rgb(102, 102, 102); text-decoration: none;"> 35</a> |
来自CODE的代码片
MainActivity.java
我们看上面代码中的“scaleY”,这是怎么来的呢?不是说ObjectAnimator需要给属性设置setter/getter方法吗?我们也没设置啊,怎么也可以执行?
带着这些疑问我们一步一步去分析一下,首先执行动画的是一个Button,Button是继承自TextView的,TextView是继承自View的。我们到View中去看一看。
<a target=_blank id="L1" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L1" rel="#L1" style="color: rgb(102, 102, 102); text-decoration: none;"> 1</a> <a target=_blank id="L2" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L2" rel="#L2" style="color: rgb(102, 102, 102); text-decoration: none;"> 2</a> <a target=_blank id="L3" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L3" rel="#L3" style="color: rgb(102, 102, 102); text-decoration: none;"> 3</a> <a target=_blank id="L4" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L4" rel="#L4" style="color: rgb(102, 102, 102); text-decoration: none;"> 4</a> <a target=_blank id="L5" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L5" rel="#L5" style="color: rgb(102, 102, 102); text-decoration: none;"> 5</a> <a target=_blank id="L6" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L6" rel="#L6" style="color: rgb(102, 102, 102); text-decoration: none;"> 6</a> <a target=_blank id="L7" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L7" rel="#L7" style="color: rgb(102, 102, 102); text-decoration: none;"> 7</a> <a target=_blank id="L8" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L8" rel="#L8" style="color: rgb(102, 102, 102); text-decoration: none;"> 8</a> <a target=_blank id="L9" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L9" rel="#L9" style="color: rgb(102, 102, 102); text-decoration: none;"> 9</a> <a target=_blank id="L10" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L10" rel="#L10" style="color: rgb(102, 102, 102); text-decoration: none;"> 10</a> <a target=_blank id="L11" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L11" rel="#L11" style="color: rgb(102, 102, 102); text-decoration: none;"> 11</a> <a target=_blank id="L12" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L12" rel="#L12" style="color: rgb(102, 102, 102); text-decoration: none;"> 12</a> <a target=_blank id="L13" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L13" rel="#L13" style="color: rgb(102, 102, 102); text-decoration: none;"> 13</a> <a target=_blank id="L14" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L14" rel="#L14" style="color: rgb(102, 102, 102); text-decoration: none;"> 14</a> <a target=_blank id="L15" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L15" rel="#L15" style="color: rgb(102, 102, 102); text-decoration: none;"> 15</a> <a target=_blank id="L16" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L16" rel="#L16" style="color: rgb(102, 102, 102); text-decoration: none;"> 16</a> <a target=_blank id="L17" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L17" rel="#L17" style="color: rgb(102, 102, 102); text-decoration: none;"> 17</a> <a target=_blank id="L18" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L18" rel="#L18" style="color: rgb(102, 102, 102); text-decoration: none;"> 18</a> <a target=_blank id="L19" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L19" rel="#L19" style="color: rgb(102, 102, 102); text-decoration: none;"> 19</a> <a target=_blank id="L20" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L20" rel="#L20" style="color: rgb(102, 102, 102); text-decoration: none;"> 20</a> <a target=_blank id="L21" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L21" rel="#L21" style="color: rgb(102, 102, 102); text-decoration: none;"> 21</a> |
来自CODE的代码片
View.java
果然,在View中已经写好了scaleY的setter和getter方法,不用我们自己去写了。除此之外,View中还已经写好了setAlpha()、setX()、setScaleX()、setTranslationX()等setter方法和对应的getter方法,我们可以拿来就用,其实这些不就是View Animation中的淡入淡出,平移,放大缩小等动画吗!
Note:如果将第24行注释掉,执行第25行。我们发现后面只有一个参数3.0f,属性的初始值没有了,照样可以执行!ObjectAnimator可以自动调用getter方法,获得当前属性的值,这就是为什么一定要有getter方法!如果将24、25行都注释掉,执行第26行,那就该报错了,因为View中没有一个"scaley"这个属性,只有"scaleY"。大小写非常重要!具体命名规则见下例
但是作为属性动画,号称是可以改变任意一个属性的,那么我们就来自定义一个属性,看看属性动画的威力!
首先我们自定义一个布局,它继承自View,目的就是画出一个数字在屏幕上
<a target=_blank id="L1" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L1" rel="#L1" style="color: rgb(102, 102, 102); text-decoration: none;"> 1</a> <a target=_blank id="L2" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L2" rel="#L2" style="color: rgb(102, 102, 102); text-decoration: none;"> 2</a> <a target=_blank id="L3" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L3" rel="#L3" style="color: rgb(102, 102, 102); text-decoration: none;"> 3</a> <a target=_blank id="L4" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L4" rel="#L4" style="color: rgb(102, 102, 102); text-decoration: none;"> 4</a> <a target=_blank id="L5" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L5" rel="#L5" style="color: rgb(102, 102, 102); text-decoration: none;"> 5</a> <a target=_blank id="L6" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L6" rel="#L6" style="color: rgb(102, 102, 102); text-decoration: none;"> 6</a> <a target=_blank id="L7" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L7" rel="#L7" style="color: rgb(102, 102, 102); text-decoration: none;"> 7</a> <a target=_blank id="L8" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L8" rel="#L8" style="color: rgb(102, 102, 102); text-decoration: none;"> 8</a> <a target=_blank id="L9" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L9" rel="#L9" style="color: rgb(102, 102, 102); text-decoration: none;"> 9</a> <a target=_blank id="L10" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L10" rel="#L10" style="color: rgb(102, 102, 102); text-decoration: none;"> 10</a> <a target=_blank id="L11" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L11" rel="#L11" style="color: rgb(102, 102, 102); text-decoration: none;"> 11</a> <a target=_blank id="L12" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L12" rel="#L12" style="color: rgb(102, 102, 102); text-decoration: none;"> 12</a> <a target=_blank id="L13" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L13" rel="#L13" style="color: rgb(102, 102, 102); text-decoration: none;"> 13</a> <a target=_blank id="L14" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L14" rel="#L14" style="color: rgb(102, 102, 102); text-decoration: none;"> 14</a> <a target=_blank id="L15" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L15" rel="#L15" style="color: rgb(102, 102, 102); text-decoration: none;"> 15</a> <a target=_blank id="L16" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L16" rel="#L16" style="color: rgb(102, 102, 102); text-decoration: none;"> 16</a> <a target=_blank id="L17" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L17" rel="#L17" style="color: rgb(102, 102, 102); text-decoration: none;"> 17</a> <a target=_blank id="L18" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L18" rel="#L18" style="color: rgb(102, 102, 102); text-decoration: none;"> 18</a> <a target=_blank id="L19" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L19" rel="#L19" style="color: rgb(102, 102, 102); text-decoration: none;"> 19</a> <a target=_blank id="L20" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L20" rel="#L20" style="color: rgb(102, 102, 102); text-decoration: none;"> 20</a> <a target=_blank id="L21" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L21" rel="#L21" style="color: rgb(102, 102, 102); text-decoration: none;"> 21</a> <a target=_blank id="L22" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L22" rel="#L22" style="color: rgb(102, 102, 102); text-decoration: none;"> 22</a> <a target=_blank id="L23" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L23" rel="#L23" style="color: rgb(102, 102, 102); text-decoration: none;"> 23</a> <a target=_blank id="L24" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L24" rel="#L24" style="color: rgb(102, 102, 102); text-decoration: none;"> 24</a> <a target=_blank id="L25" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L25" rel="#L25" style="color: rgb(102, 102, 102); text-decoration: none;"> 25</a> <a target=_blank id="L26" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L26" rel="#L26" style="color: rgb(102, 102, 102); text-decoration: none;"> 26</a> <a target=_blank id="L27" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L27" rel="#L27" style="color: rgb(102, 102, 102); text-decoration: none;"> 27</a> <a target=_blank id="L28" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L28" rel="#L28" style="color: rgb(102, 102, 102); text-decoration: none;"> 28</a> <a target=_blank id="L29" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L29" rel="#L29" style="color: rgb(102, 102, 102); text-decoration: none;"> 29</a> <a target=_blank id="L30" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L30" rel="#L30" style="color: rgb(102, 102, 102); text-decoration: none;"> 30</a> <a target=_blank id="L31" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L31" rel="#L31" style="color: rgb(102, 102, 102); text-decoration: none;"> 31</a> <a target=_blank id="L32" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L32" rel="#L32" style="color: rgb(102, 102, 102); text-decoration: none;"> 32</a> <a target=_blank id="L33" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L33" rel="#L33" style="color: rgb(102, 102, 102); text-decoration: none;"> 33</a> <a target=_blank id="L34" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L34" rel="#L34" style="color: rgb(102, 102, 102); text-decoration: none;"> 34</a> <a target=_blank id="L35" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L35" rel="#L35" style="color: rgb(102, 102, 102); text-decoration: none;"> 35</a> <a target=_blank id="L36" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L36" rel="#L36" style="color: rgb(102, 102, 102); text-decoration: none;"> 36</a> <a target=_blank id="L37" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L37" rel="#L37" style="color: rgb(102, 102, 102); text-decoration: none;"> 37</a> <a target=_blank id="L38" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L38" rel="#L38" style="color: rgb(102, 102, 102); text-decoration: none;"> 38</a> <a target=_blank id="L39" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L39" rel="#L39" style="color: rgb(102, 102, 102); text-decoration: none;"> 39</a> <a target=_blank id="L40" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L40" rel="#L40" style="color: rgb(102, 102, 102); text-decoration: none;"> 40</a> <a target=_blank id="L41" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L41" rel="#L41" style="color: rgb(102, 102, 102); text-decoration: none;"> 41</a> <a target=_blank id="L42" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L42" rel="#L42" style="color: rgb(102, 102, 102); text-decoration: none;"> 42</a> <a target=_blank id="L43" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L43" rel="#L43" style="color: rgb(102, 102, 102); text-decoration: none;"> 43</a> |
来自CODE的代码片
TempView.java
布局文件
<a target=_blank id="L1" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L1" rel="#L1" style="color: rgb(102, 102, 102); text-decoration: none;"> 1</a> <a target=_blank id="L2" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L2" rel="#L2" style="color: rgb(102, 102, 102); text-decoration: none;"> 2</a> <a target=_blank id="L3" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L3" rel="#L3" style="color: rgb(102, 102, 102); text-decoration: none;"> 3</a> <a target=_blank id="L4" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L4" rel="#L4" style="color: rgb(102, 102, 102); text-decoration: none;"> 4</a> <a target=_blank id="L5" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L5" rel="#L5" style="color: rgb(102, 102, 102); text-decoration: none;"> 5</a> <a target=_blank id="L6" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L6" rel="#L6" style="color: rgb(102, 102, 102); text-decoration: none;"> 6</a> <a target=_blank id="L7" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L7" rel="#L7" style="color: rgb(102, 102, 102); text-decoration: none;"> 7</a> <a target=_blank id="L8" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L8" rel="#L8" style="color: rgb(102, 102, 102); text-decoration: none;"> 8</a> <a target=_blank id="L9" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L9" rel="#L9" style="color: rgb(102, 102, 102); text-decoration: none;"> 9</a> <a target=_blank id="L10" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L10" rel="#L10" style="color: rgb(102, 102, 102); text-decoration: none;"> 10</a> <a target=_blank id="L11" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L11" rel="#L11" style="color: rgb(102, 102, 102); text-decoration: none;"> 11</a> <a target=_blank id="L12" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L12" rel="#L12" style="color: rgb(102, 102, 102); text-decoration: none;"> 12</a> <a target=_blank id="L13" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L13" rel="#L13" style="color: rgb(102, 102, 102); text-decoration: none;"> 13</a> <a target=_blank id="L14" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L14" rel="#L14" style="color: rgb(102, 102, 102); text-decoration: none;"> 14</a> <a target=_blank id="L15" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L15" rel="#L15" style="color: rgb(102, 102, 102); text-decoration: none;"> 15</a> <a target=_blank id="L16" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L16" rel="#L16" style="color: rgb(102, 102, 102); text-decoration: none;"> 16</a> <a target=_blank id="L17" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L17" rel="#L17" style="color: rgb(102, 102, 102); text-decoration: none;"> 17</a> <a target=_blank id="L18" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L18" rel="#L18" style="color: rgb(102, 102, 102); text-decoration: none;"> 18</a> <a target=_blank id="L19" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L19" rel="#L19" style="color: rgb(102, 102, 102); text-decoration: none;"> 19</a> <a target=_blank id="L20" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L20" rel="#L20" style="color: rgb(102, 102, 102); text-decoration: none;"> 20</a> <a target=_blank id="L21" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L21" rel="#L21" style="color: rgb(102, 102, 102); text-decoration: none;"> 21</a> <a target=_blank id="L22" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L22" rel="#L22" style="color: rgb(102, 102, 102); text-decoration: none;"> 22</a> <a target=_blank id="L23" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L23" rel="#L23" style="color: rgb(102, 102, 102); text-decoration: none;"> 23</a> |
来自CODE的代码片
main_activity.xml
最后是MainActivity
<a target=_blank id="L1" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L1" rel="#L1" style="color: rgb(102, 102, 102); text-decoration: none;"> 1</a> <a target=_blank id="L2" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L2" rel="#L2" style="color: rgb(102, 102, 102); text-decoration: none;"> 2</a> <a target=_blank id="L3" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L3" rel="#L3" style="color: rgb(102, 102, 102); text-decoration: none;"> 3</a> <a target=_blank id="L4" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L4" rel="#L4" style="color: rgb(102, 102, 102); text-decoration: none;"> 4</a> <a target=_blank id="L5" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L5" rel="#L5" style="color: rgb(102, 102, 102); text-decoration: none;"> 5</a> <a target=_blank id="L6" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L6" rel="#L6" style="color: rgb(102, 102, 102); text-decoration: none;"> 6</a> <a target=_blank id="L7" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L7" rel="#L7" style="color: rgb(102, 102, 102); text-decoration: none;"> 7</a> <a target=_blank id="L8" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L8" rel="#L8" style="color: rgb(102, 102, 102); text-decoration: none;"> 8</a> <a target=_blank id="L9" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L9" rel="#L9" style="color: rgb(102, 102, 102); text-decoration: none;"> 9</a> <a target=_blank id="L10" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L10" rel="#L10" style="color: rgb(102, 102, 102); text-decoration: none;"> 10</a> <a target=_blank id="L11" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L11" rel="#L11" style="color: rgb(102, 102, 102); text-decoration: none;"> 11</a> <a target=_blank id="L12" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L12" rel="#L12" style="color: rgb(102, 102, 102); text-decoration: none;"> 12</a> <a target=_blank id="L13" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L13" rel="#L13" style="color: rgb(102, 102, 102); text-decoration: none;"> 13</a> <a target=_blank id="L14" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L14" rel="#L14" style="color: rgb(102, 102, 102); text-decoration: none;"> 14</a> <a target=_blank id="L15" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L15" rel="#L15" style="color: rgb(102, 102, 102); text-decoration: none;"> 15</a> <a target=_blank id="L16" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L16" rel="#L16" style="color: rgb(102, 102, 102); text-decoration: none;"> 16</a> <a target=_blank id="L17" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L17" rel="#L17" style="color: rgb(102, 102, 102); text-decoration: none;"> 17</a> <a target=_blank id="L18" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L18" rel="#L18" style="color: rgb(102, 102, 102); text-decoration: none;"> 18</a> <a target=_blank id="L19" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L19" rel="#L19" style="color: rgb(102, 102, 102); text-decoration: none;"> 19</a> <a target=_blank id="L20" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L20" rel="#L20" style="color: rgb(102, 102, 102); text-decoration: none;"> 20</a> <a target=_blank id="L21" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L21" rel="#L21" style="color: rgb(102, 102, 102); text-decoration: none;"> 21</a> <a target=_blank id="L22" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L22" rel="#L22" style="color: rgb(102, 102, 102); text-decoration: none;"> 22</a> <a target=_blank id="L23" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L23" rel="#L23" style="color: rgb(102, 102, 102); text-decoration: none;"> 23</a> <a target=_blank id="L24" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L24" rel="#L24" style="color: rgb(102, 102, 102); text-decoration: none;"> 24</a> <a target=_blank id="L25" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L25" rel="#L25" style="color: rgb(102, 102, 102); text-decoration: none;"> 25</a> <a target=_blank id="L26" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L26" rel="#L26" style="color: rgb(102, 102, 102); text-decoration: none;"> 26</a> <a target=_blank id="L27" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L27" rel="#L27" style="color: rgb(102, 102, 102); text-decoration: none;"> 27</a> <a target=_blank id="L28" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L28" rel="#L28" style="color: rgb(102, 102, 102); text-decoration: none;"> 28</a> <a target=_blank id="L29" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L29" rel="#L29" style="color: rgb(102, 102, 102); text-decoration: none;"> 29</a> <a target=_blank id="L30" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L30" rel="#L30" style="color: rgb(102, 102, 102); text-decoration: none;"> 30</a> <a target=_blank id="L31" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L31" rel="#L31" style="color: rgb(102, 102, 102); text-decoration: none;"> 31</a> <a target=_blank id="L32" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L32" rel="#L32" style="color: rgb(102, 102, 102); text-decoration: none;"> 32</a> <a target=_blank id="L33" href="http://blog.youkuaiyun.com/nugongahou110/article/details/46722595#L33" rel="#L33" style="color: rgb(102, 102, 102); text-decoration: none;"> 33</a> |
来自CODE的代码片
MainActivity.java
最后的效果:
怎么样,属性动画很厉害吧。这可是View Animation做不了的!
ObjectAnimator我们就分析完了,下一篇我们来分析ValueAnimator Android属性动画-Property Animation(三) 使用ValueAnimator完成动画
版权声明:欢迎转载,转载请注明出处http://blog.youkuaiyun.com/nugongahou110