Android转场动画和共享元素动画兼容5.0以下版本的实现

原创 cheny  2018-04-26 00:51  阅读 720 次 评论 0 条
摘要:

本来计划先把相关开源库写好发布后再写博客的,最近受到感情挫伤,暂时无心写博客,仅仅把开源库收尾发布了,然后本文先摘些开源库readme部分内容,后续博客是否更新说教内容再看情况吧

版权说明 : 《Android转场动画和共享元素动画兼容5.0以下版本的实现》于当前CSDN博客乘月网属同一原创,转载请说明出处,谢谢。

本来计划先把相关开源库写好发布后再写博客的,最近受到感情挫伤,暂时无心写博客,仅仅把开源库收尾发布了,然后本文先摘些开源库readme部分内容,后续博客是否更新说教内容再看情况吧...

CySharedElementTransition

A compat library of android shared-element transition for lower api.
一个为Android较低版本api提供Android共享元素转场动画的兼容库。

开源库地址:https://github.com/ausboyue/CySharedElementTransition

ScreenShot

easytransition

Download from Gradle

Add to your root build.gradle:

allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}

Add the dependency:

dependencies {
    implementation 'com.github.ausboyue:CySharedElementTransition:1.0.0'
}

Friendly Hints

If you can't download it, maybe you have used the Google's repository that you can't connect to the Google server.Please open the proxy or top the target repository.As follows(如果你无法下载这个库,你可能使用了google的仓库。请开启代理或者置顶目标仓库,如下所示):

allprojects {
    repositories {
        maven { url 'https://jitpack.io' } // target repository,be top
        jcenter()
        google() // Google's repository
    }
}

Download from Maven

Add the JitPack repository to your build file:

<repositories>
    <repository>
        <id>jitpack.io</id>
        <url>https://jitpack.io</url>
    </repository>
</repositories>

Add the dependency:

<dependency>
    <groupId>com.github.ausboyue</groupId>
    <artifactId>CySharedElementTransition</artifactId>
    <version>1.0.0</version>
</dependency>

Get Started

1. ActivityA jump to ActivityB,when need use "SharedElementTransition"(ActivityA 跳转到ActivityB,当需要用到“共享元素转场动画”时):

  • ActivityA edit code as below(编辑ActivityA 的代码如下):
    ElementTransition.startActivity(intent, activityA, view1, view2, view...);
  • ActivityB edit code as below(编辑ActivityB 的代码如下):
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ......
        ElementTransition.runEnterAnim(activityB);
        ......
    }

2. ActivityB back to ActivityA(ActivityB Ac回到ActivityA):

  • ActivityB edit code like this(编辑ActivityB 的代码,类似代码如下):
    @Override
    public void onBackPressed() {
        ElementTransition.runExitAnim(activityB);
    }

好了,就这样了,让大家失望了,我可能失去了奋斗的动力,但迟早会回来的。

本文地址:https://www.icheny.cn/archives/850
关注公众号“我的IT小地方”:扫二维码乘月网的公众号 or 搜索公众号:it_place
版权声明:本文为原创文章,版权归 cheny 所有,欢迎分享本文,转载请保留出处!

发表评论


表情