public class AnimTest extends Activity{
// ....生命周期方法略
public void startAnim(View view, int deltaY){
MyAnim anim = new MyAnim(view,deltaY,true);
anim.setFillAfter(true);
anim.setFillEnabled(true);
anim.setDuration(500);
anim.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
button1.setEnabled(false);
button2.setEnabled(true);
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
button1.setVisibility(View.INVISIBLE);
button2.setVisibility(View.VISIBLE);
}
});
view.startAnimation(anim);
}
class MyAnim extends Animation {
private View view;
private int deltaY;
private boolean initiallyCollapsed;
public MyAnim(View view, int deltaY, boolean initiallyCollapsed) {
this.view = view;
this.deltaY = deltaY;
this.initiallyCollapsed = initiallyCollapsed;
}
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
int newHeight;
if (this.initiallyCollapsed) {
newHeight = (int) (this.deltaY * interpolatedTime);
} else {
newHeight = (int) (this.deltaY * (1 - interpolatedTime));
}
view.getLayoutParams().height = newHeight;
view.requestLayout();
}
@Override
public void initialize(int width, int height, int parentWidth, int parentHeight) {
super.initialize(width, height, parentWidth, parentHeight);
}
}
}
分享到:
相关推荐
博客讲解地址http://blog.csdn.net/wingichoy/article/details/47122619
NULL 博文链接:https://trylovecatch.iteye.com/blog/1199120
Animation动画的解析与自定义Animation动画
Android自定义View 星球运动在dribbble闲逛的时候发现的一个有意思的星球运动的动画,刚好最近时间尚可,就简单实现了一下中间运动的部分,又是因为时间的原因,开头位移的部分没有完成. 这是在dribbble中发现的动画 ...
使用android逐帧动画实现自定义loading进度条。
private Animation pointRotationAnima(float fromDegrees, float toDegrees) { int initDegress = 306;// 进度点起始位置(图片偏移约54度) RotateAnimation animation = new RotateAnimation(fromDegrees, ...
主要为大家详细介绍了Android自定义Animation实现View摇摆效果,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
Android 自定义 orc 。身份证 银行卡认证。扫描认证。主动识别、 android.graphics.Camera; import android.graphics.Matrix; import android.view.animation.Animation; import android.view.animation....
Android 补间动画 Animation 各个动画的例子 Animation使用到自定义View里
It has smooth zoom-in, zoom-out animation when switched from one fragment to another. Still in Active Development. Version Installation Gradle Add it in your root build.gradle at the end of ...
> TreeView implementation in Android. 中文版 Features TreeView File Explorer(Advanced Example) ①Multi-level tree view Basic file manager layout ②Remember expansion state Automatically ...
Android 自定义 View 基础和原理实现 1.绘制下雨场景的个体、雨点(直线) 2.让直线动起来 3.处理边界问题 4.构造雨点对象 5.雨点大小设置 6.速度设置和角度设置等 7.添加多个雨点 8.抽离可以在 XML 中影响的属性
Android 实现卫星式菜单也叫弧形菜单,主要要做的工作如下: 1.动画的处理 2.自定义ViewGroup来实现卫星式菜单View (1)自定义属性 a. 在attrs.xml中定义属性 b. 在布局中使用自定义属性 c. 在自定义...
cc.util.android.view,则需要再创建一个包cc.util.android.view.image 然后将图片拷贝进去 /****************从此出开始将代码拷贝到一个文件中*******************/ package cc.util.android.view; import java....
Android Tween Animation动画的使用demo,以及自定义动画,原理解析,相关博客: http://blog.csdn.net/w18756901575/article/details/53081551
android View自定义动画,简单的实现
Android开发中,如何在View中添加Animation,有此需求的朋友可以参看一下本源码,该源码该也比较适合初学者。
详细讲解了android中的几种动画以及自定义动画的方式。
使用Drawable Animation完成的加载动画自定义控件