所在包:com.example.android.apis.view
apidemo还是有非常多的好东西的 作为初学者 必须看啊
首先是一个一个叠下来的动画
很简单 gridview中的:
android:layoutAnimation="@anim/layout_grid_fade"
<?xml version="1.0" encoding="utf-8"?>
<gridLayoutAnimation xmlns:android="http://schemas.android.com/apk/res/android"
android:animation="@anim/fade"
android:directionPriority="column"
android:rowDelay="50%" />
fade
<?xml version="1.0" encoding="utf-8"?>
<gridLayoutAnimation xmlns:android="http://schemas.android.com/apk/res/android"
android:animation="@anim/fade"
android:directionPriority="column"
android:rowDelay="50%" />
然后是listview 的从上面甩下来:
AnimationSet set = new AnimationSet(true);
Animation animation = new AlphaAnimation(0.0f, 1.0f);
animation.setDuration(50);
set.addAnimation(animation);
animation = new TranslateAnimation(
Animation.RELATIVE_TO_SELF, 0.0f,Animation.RELATIVE_TO_SELF, 0.0f,
Animation.RELATIVE_TO_SELF, -1.0f,Animation.RELATIVE_TO_SELF, 0.0f
);
animation.setDuration(100);
set.addAnimation(animation);
LayoutAnimationController controller = new LayoutAnimationController(set, 0.5f);
ListView listView = getListView();
listView.setLayoutAnimation(controller);
向上甩上去
演示用用xml实现
android:layoutAnimation="@anim/layout_bottom_to_top_slide"
<?xml version="1.0" encoding="utf-8"?>
<layoutAnimation xmlns:android="http://schemas.android.com/apk/res/android"
android:animation="@anim/slide_right"
android:animationOrder="reverse"
android:delay="30%" />
slide_right
<?xml version="1.0" encoding="utf-8"?>
<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>
GridView 随机显示item
android:layoutAnimation="@anim/layout_random_fade"
<?xml version="1.0" encoding="utf-8"?>
<layoutAnimation xmlns:android="http://schemas.android.com/apk/res/android"
android:delay="0.5"
android:animationOrder="random"
android:animation="@anim/fade" />
fade
<?xml version="1.0" encoding="utf-8"?>
<gridLayoutAnimation xmlns:android="http://schemas.android.com/apk/res/android"
android:animation="@anim/fade"
android:directionPriority="column"
android:rowDelay="50%" />
从下到上的显示item
<?xml version="1.0" encoding="utf-8"?>
<gridLayoutAnimation xmlns:android="http://schemas.android.com/apk/res/android"
android:columnDelay="0.5"
android:directionPriority="row"
android:direction="right_to_left|bottom_to_top"
android:animation="@anim/fade" />
其他两个感觉不是很好 不介绍了