Urb*_*ndu 2 animation android android-gridview
我正在尝试GridView类似于这个http://framerjs.com/examples/preview/#delayed-animations.framer的动画.我尝试了slideUp动画,GridView但所有列都在同一点移动.我需要它类似于上面的链接.
Anm*_*Rai 10
使用GridLayoutAnimationController进行网格项动画.
Animation animation = AnimationUtils.loadAnimation(getContext(),R.anim.grid_item_anim);
GridLayoutAnimationController controller = new GridLayoutAnimationController(animation, .2f, .2f);
mGrid.setLayoutAnimation(controller);
Run Code Online (Sandbox Code Playgroud)
grid_item_anim.
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >
<translate
android:duration="1000"
android:fromYDelta="100%p"
android:interpolator="@android:anim/linear_interpolator"
android:toYDelta="0%p" />
</set>
Run Code Online (Sandbox Code Playgroud)
在网格视图布局中将动画布局更改添加为true
android:animateLayoutChanges="true"
Run Code Online (Sandbox Code Playgroud)
在“res”下创建一个名为“anim”的文件夹,在“anim”内创建一个名为 animation_move.xml(可以是任何名称)的 xml 文件。这个应用程序在 GridView 中使用了一些动画。社交贴纸
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >
<translate
android:duration="5000"
android:fromYDelta="0%p"
android:interpolator="@android:anim/cycle_interpolator"
android:toYDelta="100%p" />
</set>
Run Code Online (Sandbox Code Playgroud)
并在您的适配器类中,进行初始化
Animation animation = AnimationUtils.loadAnimation(context, R.anim.animation_move);
Run Code Online (Sandbox Code Playgroud)
在 getview 函数中,假设您使用的是图像
picture = (ImageView) v.getTag(R.id.picture);
picture.setImageResource(item.drawableId);
picture.startAnimation(animation);
Run Code Online (Sandbox Code Playgroud)
您的 getview 函数可能不同,但此代码会给您提示。
| 归档时间: |
|
| 查看次数: |
7787 次 |
| 最近记录: |