转载请声明地址:http://blog.csdn.net/skyunicorn/article/details/51691965
Demo_PullToRefresh(基础篇)
Demo_PullToRefresh(进阶篇)
package com.demo.demo_pulltorefresh;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.AnimationSet;
import android.view.animation.LayoutAnimationController;
import android.view.animation.TranslateAnimation;
/**
* 设置布局从右侧进入的动画
*
* Created by YangJW on 2016/6/15 14:56.
*/
public class Utils_LayoutAnimation
{
// 从右侧进入
public static LayoutAnimationController LayoutAnimatioRightIn()
{
LayoutAnimationController controller = new LayoutAnimationController(
AnimationRightIn(), 0.5f);
return controller;
}
// 从上方掉落
public static LayoutAnimationController LayoutAnimatioTopIn()
{
LayoutAnimationController controller = new LayoutAnimationController(
AnimationTopIn(), 0.5f);
return controller;
}
// 从下方吸引
public static LayoutAnimationController LayoutAnimatioDownIn()
{
LayoutAnimationController controller = new LayoutAnimationController(
AnimationDownIn(), 0.5f);
return controller;
}
// 右侧进入动画
public static AnimationSet AnimationRightIn()
{
AnimationSet set = new AnimationSet(true);
Animation animation = new AlphaAnimation(0.0f, 1.0f);
animation.setDuration(300);
set.addAnimation(animation);
animation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 1.0f,
Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF,
0.0f, Animation.RELATIVE_TO_SELF, 0.0f);
animation.setDuration(500);
set.addAnimation(animation);
return set;
}
// 上方掉落动画
public static AnimationSet AnimationTopIn(){
AnimationSet set = new AnimationSet(true);
Animation animation = new AlphaAnimation(0.0f, 1.0f);
animation.setDuration(300);
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(500);
set.addAnimation(animation);
return set;
}
// 下方吸引动画
public static AnimationSet AnimationDownIn(){
AnimationSet set = new AnimationSet(true);
Animation animation = new AlphaAnimation(0.0f, 1.0f);
animation.setDuration(300);
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(500);
set.addAnimation(animation);
return set;
}
}
// 设置LayoutAnimaiton
private void initLayoutAnimation()
{
// 右侧进入动画
lv.setLayoutAnimation(Utils_LayoutAnimation.LayoutAnimationRightIn());
// 上方掉落动画
// lv.setLayoutAnimation(Utils_LayoutAnimation.LayoutAnimationTopIn());
// 下方吸引动画
// lv.setLayoutAnimation(Utils_LayoutAnimation.LayoutAnimationDownIn());
}
从下方吸引的
Demo地址:http://download.csdn.net/detail/skyunicorn/9551436