Android layoutanimation的应用
来源:互联网 发布:淘宝联盟怎么发链接 编辑:程序博客网 时间:2024/04/30 08:16
layoutanimation作用于viewgroup,为viewgroup指定一个动画,这样当他的子元素出场时就具有这种动画效果。让我们来看看特殊的listview,他的每个item都已特殊的动画出现。
<layoutAnimation xmlns:android="http://schemas.android.com/apk/res/android" android:animation="@anim/anim_item" android:animationOrder="reverse" android:delay="0.5" />
delay子元素开始动画事件延迟
animationOrder表示出场次序 有normal 正常次序,random随机入场,reverse 倒叙入场,animation 具体入场动画为子元素指定入场动画
<?xml version="1.0" encoding="utf-8"?><set xmlns:android="http://schemas.android.com/apk/res/android" android:duration="300" android:interpolator="@android:anim/accelerate_interpolator" android:shareInterpolator="true" > <alpha android:fromAlpha="0.0" android:toAlpha="1.0" /> <translate android:fromXDelta="500" android:toXDelta="0" /></set>
为viewgroup指定layoutanimation属性,
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <ListView android:id="@+id/listview" android:layout_width="match_parent" android:layout_height="match_parent" android:layoutAnimation="@anim/anim_layout" > </ListView></LinearLayout>除了在xml内指定layoutanimation之外,还可以在代码里实现:
listview = (ListView) findViewById(R.id.listview);Animation animation = AnimationUtils.loadAnimation(ListLayOut.this,R.anim.anim_item);LayoutAnimationController controller = new LayoutAnimationController(animation);controller.setDelay(0.5f);controller.setOrder(LayoutAnimationController.ORDER_NORMAL);listview.setLayoutAnimation(controller);2、activity的切换效果
activity的切换是有固定的动画的,但是我们也可以自己来定义,主要由overridependingtransition(int enteranimation , int exitanimation),这个方法必须在startactivity之后或者在finish之后调用才有效,他的参数含义如下:
enteranimation activity被打开时的动画资源id
exitanimation activity被暂停时的动画资源id
public static void startActivity(Activity activity) {Intent intent = new Intent(activity, ListLayOut.class);activity.startActivity(intent);activity.overridePendingTransition(R.anim.anim_item, R.anim.anim_item2);}当然也可以给fragment添加出入动画,但是只能添加view动画,不能田间属性动画。所以兼容性比较低。
0 0
- Android layoutanimation的应用
- Android --- layoutAnimation应用
- Android layoutAnimation简单应用
- Android layoutAnimation简单应用,让你的应用提高逼格
- Android LayoutAnimation
- Android LayoutAnimation
- Android LayoutAnimation
- android LayoutAnimation
- Android的Animation之LayoutAnimation使用方法
- Android的Animation之LayoutAnimation使用方法
- Android的Animation之LayoutAnimation使用方法
- Android的Animation之LayoutAnimation使用方法
- Android的Animation之LayoutAnimation使用方法
- Android的Animation之LayoutAnimation使用方法
- Android-LayoutAnimation(布局动画)的学习
- Android LayoutAnimation 与 LayoutTransition
- 7.3 Android Framework - LayoutAnimation
- Android LayoutAnimation使用
- No module named 'MySQLdb'(第一次django下创建数据库迁移,报错)
- AC自动机的一种简单实现
- leetcode28: Implement strStr()
- python学习记录-- 数据结构----列表篇
- 代码整洁之道笔记(三)
- Android layoutanimation的应用
- “互联网+制造”模式将成推动工业革命的核心要素
- sigslot库源码分析
- Jquery基础之DOM操作
- 在IntelliJ IDEA上操作GitHub
- 有关职场的一些个人经验
- 带宽
- 容器网络Calico进阶实践
- kairosDB