• Android View 从左边滑出动画 ,以及从左上,左下,右上,右下放大动画。


    1.从左边滑出动画。

    ViewTreeObserver vtobanniang = ivBanniang.getViewTreeObserver();
    vtobanniang.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
    @Override
    public void onGlobalLayout() {
    ivBanniang.getViewTreeObserver().removeOnGlobalLayoutListener(this);
    int width = ivBanniang.getWidth();
    float[] x = {-width, 0};
    ObjectAnimator objectAnimatorX = ObjectAnimator.ofFloat(ivBanniang, "translationX", x);
    objectAnimatorX.setDuration(500);
    objectAnimatorX.start();
    }
    });

    2.从左上,左下,右上,右下放大出场动画。

    中心点更改为左下角:
    mGenderSelectorLinearLayout.setPivotX(0);
    mGenderSelectorLinearLayout.setPivotY(mGenderSelectorLinearLayout.getHeight());

    中心点更改为左上角:
    mGenderSelectorLinearLayout.setPivotX(0);

    mGenderSelectorLinearLayout.setPivotY(0);

     

    中心点更改为右上角:

    mGenderSelectorLinearLayout.setPivotX(mGenderSelectorLinearLayout.getWidth()); mGenderSelectorLinearLayout.setPivotY(0);

    中心点更改为右下角:

    mGenderSelectorLinearLayout.setPivotX(mGenderSelectorLinearLayout.getWidth());
    mGenderSelectorLinearLayout.setPivotY(mGenderSelectorLinearLayout.getHeight());


    动画:

    public void showGenderSelectorAnimation() {
        if (mGenderSelectorLinearLayout == null) {return;}
        mGenderSelectorLinearLayout.post(new Runnable() {
            @Override
            public void run() {
                mGenderSelectorLinearLayout.setPivotX(0);
                mGenderSelectorLinearLayout.setPivotY(mGenderSelectorLinearLayout.getHeight());
                ObjectAnimator scaleX = ObjectAnimator.ofFloat(mGenderSelectorLinearLayout, "scaleX", 0.0f, 1.05f);
                ObjectAnimator scaleY = ObjectAnimator.ofFloat(mGenderSelectorLinearLayout, "scaleY", 0.0f, 1.05f);
                AnimatorSet set = new AnimatorSet();
                set.play(scaleX).with(scaleY);
                set.setDuration(330);
                set.start();
                set.addListener(new AnimatorListenerAdapter() {
                    @Override
                    public void onAnimationEnd(Animator animation) {
                        super.onAnimationEnd(animation);
                        if (mGenderSelectorLinearLayout == null) {
                            return;
                        }
                        ObjectAnimator scaleX2 = ObjectAnimator.ofFloat(mGenderSelectorLinearLayout, "scaleX", 1.05f, 0.98f);
                        ObjectAnimator scaleY2 = ObjectAnimator.ofFloat(mGenderSelectorLinearLayout, "scaleY", 1.05f, 0.98f);
                        AnimatorSet set2 = new AnimatorSet();
                        set2.play(scaleX2).with(scaleY2);
                        set2.setDuration(150);
                        set2.start();
                        set2.addListener(new AnimatorListenerAdapter() {
                            @Override
                            public void onAnimationEnd(Animator animation) {
                                super.onAnimationEnd(animation);
                                if (mGenderSelectorLinearLayout == null) {
                                    return;
                                }
                                ObjectAnimator scaleX3 = ObjectAnimator.ofFloat(mGenderSelectorLinearLayout, "scaleX", 0.98f, 1.0f);
                                ObjectAnimator scaleY3 = ObjectAnimator.ofFloat(mGenderSelectorLinearLayout, "scaleY", 0.98f, 1.0f);
                                AnimatorSet set3 = new AnimatorSet();
                                set3.play(scaleX3).with(scaleY3);
                                set3.setDuration(300);
                                set3.start();
                            }
                        });
                    }
                });
            }
        });
    }
    
  • 相关阅读:
    搜索二维矩阵 240
    238 除自身以外数组的乘积 左右乘积数组
    160 相交链表
    152乘积最大子数组 dp
    leetcode 739 每日温度 单调栈
    543求二叉树的直径
    IOS 支付相关
    Intellij IDEA--can't use subversion command line client : svn
    每日日报34——通过SQL语句将某个字段的括号给去掉
    每日日报33——VisualStudio2013代码格式化快捷键+给窗体添加按钮
  • 原文地址:https://www.cnblogs.com/lixiangyang521/p/13269247.html
Copyright © 2020-2023  润新知