当前位置: 代码迷 >> Android >> android奇效展示一:ListView
  详细解决方案

android奇效展示一:ListView

热度:79   发布时间:2016-05-01 17:20:46.0
android特效展示一:ListView

ViewGroup等空间的动画效果实战
常常我们会为一些空间制定动画效果,当然也能在布局空间中制定动画效果:
如:
<ListView
? ?? ???android:id="@android:id/list"
? ?? ???android:persistentDrawingCache="animation|scrolling"
? ?? ???android:layout_width="fill_parent"
? ?? ???android:layout_height="fill_parent"
? ?? ???android:layoutAnimation="@anim/layout_bottom_to_top_slide" />
android:layoutAnimation="@anim/layout_bottom_to_top_slide" 制定了该组建显示的时候的动画效果
layoutAnimation指定了前面定义的LayoutAnimationController,为了使动画效果比较流畅这里还通过persistentDrawingCache设置了控件的绘制缓存策略,一共有4中策略:
PERSISTENT_NO_CACHE 说明不在内存中保存绘图缓存;
PERSISTENT_ANIMATION_CACHE 说明只保存动画绘图缓存;
PERSISTENT_SCROLLING_CACHE 说明只保存滚动效果绘图缓存
PERSISTENT_ALL_CACHES 说明所有的绘图缓存都应该保存在内存中。

layout_bottom_to_top_slide 的代码如下
<layoutAnimation xmlns:android="http://schemas.android.com/apk/res/android"
? ?? ?? ???android:delay="70%"
? ?? ???android:animationOrder="random"
? ?? ???android:animation="@anim/slide_right" />
android:delay??子类动画时间间隔 (延迟)? ?70% 也可以是一个浮点数 如“1.2”等
android:animationOrder="random"? ?子类的显示方式 random表示随机
android:animationOrder 的取值有
normal? ?? ???0? ?? ?? ???默认
reverse? ?? ???1? ?? ?? ? 倒序
random? ?? ???2? ?? ?? ? 随机
android:animation="@anim/slide_right" 表示孩子显示时的具体动画是什么

slide_right.xml
<set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/accelerate_interpolator">
? ? <translate android:fromXDelta="-100%p" android:toXDelta="0"
? ?? ?? ?? ?android:duration="@android:integer/config_shortAnimTime" />
</set>
不用解释了啥 就是动画又左边显示出来
中上所述 显示的效果为ListView第一次出现的时候为 item随机出现 每个Item都是从左不可见(-100%p)的区域向右滑动到显示的地方

?

?

转载请注明:来源于http://hi.baidu.com/adnroidorg/home

  相关解决方案