• 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();
                            }
                        });
                    }
                });
            }
        });
    }
    
  • 相关阅读:
    C#面向过程之类型转换、算术运算符、关系运算符、逻辑运算符、if-else语句、switch-case、循环结构(while、for)、三元表达式
    C#面向过程之编译原理、变量、运算符
    VS快捷键整理
    简单聊聊mybatis插件(附源码)
    高性能页面加载技术(流水线加载)BigPipe的C#简单实现(附源码)
    聊聊js运算符 ‘与(&&)’和‘ 或(||)’
    从内部剖析C# 集合之--Dictionary
    从内部剖析C# 集合之---- HashTable
    字符串查找和函数操作题目解析
    常用排序算法实现
  • 原文地址:https://www.cnblogs.com/lixiangyang521/p/13269247.html
Copyright © 2020-2023  润新知