淡入淡出
来源:互联网 发布:java每5个数输出一行 编辑:程序博客网 时间:2024/04/30 13:37
import android.os.Handler;
import android.os.Message;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
/**
* 淡入淡出
*
* @author l
*
*/
public class FadeUitl {
// 淡出
// ①谁在执行淡出动画:当前正在展示的界面
// ②淡出的时间
// ③在淡出执行完成后,删除淡出的界面
// 淡入
// ①谁在执行淡入动画:目标界面
// ②淡入的时间
// ③淡入的等待时间:淡出界面的执行动画时间
private static Handler handler=new Handler(){
public void handleMessage(Message msg) {
View currentView=(View) msg.obj;
ViewGroup middle = (ViewGroup) currentView.getParent();
middle.removeView(currentView);
}
};
/**
* 淡出
*
* @param currentView
* @param duration
*/
public static void fadeOut(final View currentView, long duration) {
// where 1.0 means fully opaque and 0.0 means fully transparent.
AlphaAnimation animation = new AlphaAnimation(1, 0);
animation.setDuration(duration);
// 动画执行完成后,停留在执行的终点上
// animation.setFillAfter(true);
// 动画执行完成后,删除currentView
animation.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
// 删除currentView
// middle.removeView(child1);
// ViewGroup middle = (ViewGroup) currentView.getParent();
// middle.removeView(currentView);
Message msg=Message.obtain();
msg.obj=currentView;
// handler.sendMessageDelayed(msg, 1);
handler.sendMessage(msg);
}
});
currentView.startAnimation(animation);
}
/**
* 淡入
*
* @param currentView
* @param duration
*/
public static void fadeIn(View targetView, long duration, long delay) {
// where 1.0 means fully opaque and 0.0 means fully transparent.
AlphaAnimation animation = new AlphaAnimation(0, 1);
animation.setDuration(duration);
// 延迟播放动画
animation.setStartOffset(delay);
targetView.startAnimation(animation);
}
}
import android.os.Message;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
/**
* 淡入淡出
*
* @author l
*
*/
public class FadeUitl {
// 淡出
// ①谁在执行淡出动画:当前正在展示的界面
// ②淡出的时间
// ③在淡出执行完成后,删除淡出的界面
// 淡入
// ①谁在执行淡入动画:目标界面
// ②淡入的时间
// ③淡入的等待时间:淡出界面的执行动画时间
private static Handler handler=new Handler(){
public void handleMessage(Message msg) {
View currentView=(View) msg.obj;
ViewGroup middle = (ViewGroup) currentView.getParent();
middle.removeView(currentView);
}
};
/**
* 淡出
*
* @param currentView
* @param duration
*/
public static void fadeOut(final View currentView, long duration) {
// where 1.0 means fully opaque and 0.0 means fully transparent.
AlphaAnimation animation = new AlphaAnimation(1, 0);
animation.setDuration(duration);
// 动画执行完成后,停留在执行的终点上
// animation.setFillAfter(true);
// 动画执行完成后,删除currentView
animation.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
// 删除currentView
// middle.removeView(child1);
// ViewGroup middle = (ViewGroup) currentView.getParent();
// middle.removeView(currentView);
Message msg=Message.obtain();
msg.obj=currentView;
// handler.sendMessageDelayed(msg, 1);
handler.sendMessage(msg);
}
});
currentView.startAnimation(animation);
}
/**
* 淡入
*
* @param currentView
* @param duration
*/
public static void fadeIn(View targetView, long duration, long delay) {
// where 1.0 means fully opaque and 0.0 means fully transparent.
AlphaAnimation animation = new AlphaAnimation(0, 1);
animation.setDuration(duration);
// 延迟播放动画
animation.setStartOffset(delay);
targetView.startAnimation(animation);
}
}
0 0
- 淡入淡出
- 淡入淡出
- 淡入淡出
- 淡入淡出
- 页面淡入淡出效果
- 图象淡入淡出
- 图象淡入淡出(VB6)
- msn淡入淡出窗口
- C#淡出淡入窗体
- 淡出淡入窗体
- 淡入淡出的文字效果
- C#淡出淡入窗体
- 8.4 淡入和淡出
- 淡入、淡出效果
- 图片淡入淡出
- 淡入淡出效果
- 窗口淡入淡出效果
- 提示框淡入淡出
- Makefile 使用总结
- Scala的ClassTag
- B族树详解(二叉搜索树、B-树、B+树、B*树)
- 方便的弹出视图,可随意定义箭头方向,自动计算位置
- 堆排序
- 淡入淡出
- 蓝牙5新时代来临,或搭载iphone7,蓝牙新时代
- 栈的应用之数制转换
- kettle表数据同步
- javascript小记——setTimeout调用方法总是提示未定义??
- RecyclerView设置 item点击事件
- Fragment嵌套使用时,从主页面回到应用时出现的异常问题
- 网络——XML基础知识
- 树:红黑树