ViewExpandAnimation

Posted aikongmeng

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ViewExpandAnimation相关的知识,希望对你有一定的参考价值。

N 年前写的展开动画,古董代码片分享一下

import android.view.View;
import android.view.animation.Animation;
import android.view.animation.Transformation;
import android.widget.LinearLayout.LayoutParams;

public class ViewExpandAnimation extends Animation 
    private View mAnimationView = null;
    private LayoutParams mViewLayoutParams = null;
    private int mStart = 0;
    private int mEnd = 0;

    public ViewExpandAnimation(View view) 
        animationSettings(view, 500);
    

    public ViewExpandAnimation(View view, int duration) 
        animationSettings(view, duration);
    

    private void animationSettings(View view, int duration) 
        setDuration(duration);
        mAnimationView = view;
        mViewLayoutParams = (LayoutParams) view.getLayoutParams();
        mStart = mViewLayoutParams.bottomMargin;
        mEnd = (mStart == 0 ? (0 - view.getHeight()) : 0);
        view.setVisibility(View.VISIBLE);
    

    @Override
    protected void applyTransformation(float interpolatedTime, Transformation t) 
        super.applyTransformation(interpolatedTime, t);

        if (interpolatedTime < 1.0f) 
            mViewLayoutParams.bottomMargin = mStart + (int) ((mEnd - mStart) * interpolatedTime);
            // invalidate
            mAnimationView.requestLayout();
         else 
            mViewLayoutParams.bottomMargin = mEnd;
            mAnimationView.requestLayout();
            if (mEnd != 0) 
                mAnimationView.setVisibility(View.GONE);
            
        
    

    public View getAnimationView() 
        return mAnimationView;
    

以上是关于ViewExpandAnimation的主要内容,如果未能解决你的问题,请参考以下文章

ViewExpandAnimation

没技术改造的“古董项目”ci交付就是面子工程

没技术改造的“古董项目”ci交付就是面子工程

同步拍 | 美国 Maven 亚洲古董艺术品拍卖会精品抢先看

QTP常用老古董function

在macOSWindows和Linux上体验古董系统Mac OS 8