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

微信小程序代码片段

VSCode自定义代码片段——CSS选择器

谷歌浏览器调试jsp 引入代码片段,如何调试代码片段中的js

片段和活动之间的核心区别是啥?哪些代码可以写成片段?

VSCode自定义代码片段——.vue文件的模板