具有自定义持续时间的ActivityOptionsCompat.makeSceneTransitionAnimation [英] ActivityOptionsCompat.makeSceneTransitionAnimation with custom duration

查看:690
本文介绍了具有自定义持续时间的ActivityOptionsCompat.makeSceneTransitionAnimation的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为API级别20以上的设备进行场景转换。它工作正常,但我想设置自定义持续时间以进行过渡。

I'm making a scene transition for devices with API level 20+. It is working fine, but I want to set custom duration to make the transition. Is it possible ??

我的代码是否可能?

ActivityOptionsCompat options =

                ActivityOptionsCompat.makeSceneTransitionAnimation(this,
                        viewStart,
                        transitionName
                );

        ActivityCompat.startActivity(this, detailsIntent, options.toBundle());


推荐答案

您可以在新开始的活动中设置所需的持续时间,通过添加以下内容:

You can set the desired duration in the new started activity, by adding:

    ChangeBounds bounds = new ChangeBounds();
    bounds.setDuration(2000);
    getWindow().setSharedElementEnterTransition(bounds);

这篇关于具有自定义持续时间的ActivityOptionsCompat.makeSceneTransitionAnimation的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆