Code Monkey home page Code Monkey logo

androidskinanimator's Introduction

换肤方案:

Android-skin-support

换肤时增加了动画

增加了一些View动画

全局动画

全局动画和换肤原理相同,直接替换了View组件,原理可以参考Android-skin-support

原理概述

了解过换肤框架的同学知道,利用setFactory(LayoutInflater inflater, LayoutInflaterFactory factory)可以在不更新布局文件的情况下替换布局中View为自定义View,并且对开发者透明。利用这个原理我们可以把原生的View替换为支持动画的View,如TexView在执行setText、setVisibility等操作时执行动画。

同时提供动画执行等开关,在需要时打开,在不需要时关闭即可。

使用说明

  • 1.继承SkinCompatActivity, 同时支持了换肤功能

  • 2.如果Activity需要支持全局动画,覆盖方法:

    @Override
    protected boolean needAnimator() {
        return true;
    }

如果不需要,则不用理会

  • 3.在Activity中设置动画配置:
        setAnimatorConfig(new AnimatorConfig
                .Builder()
                .textviewTextAnimationType(ViewAnimatorType.AlphaUpdateAnimator)
                .textviewVisibleAnimationType(ViewAnimatorType.TranslationAlphaHideAnimator)
                .build());

在其它地方设置配置:

AnimatorManager.setConfig(new AnimatorConfig.Builder()
                        .textviewVisibleAnimationType(ViewAnimatorType.TranslationAlphaHideAnimator)
                        .textviewTextAnimationType(ViewAnimatorType.AlphaUpdateAnimator)
                        .build());
  • 4.在需要的地方打开关闭动画:
AnimatorManager.openAnimator();

AnimatorManager.closeAnimator();

致谢

欢迎关注公众号wutongke,每天推送移动开发前沿技术文章:

wutongke

androidskinanimator's People

Contributors

wutongke avatar ximsfei avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.