如何将makeSceneTransitionAnimation转换为圆形,而不是矩形?

时间:2015-03-07 08:13:27

标签: android android-5.0-lollipop activity-transition circularreveal

我目前正在尝试在我的FAB和另一个Activity之间创建一个循环过渡。

根据我在文档中提到的内容,我应该以类似的方式使用makeSceneTransitionAnimation:

public void onFabClicked(View v){
    try {
        Intent intent = new Intent(this, SearchActivity.class);
        ActivityOptions options = ActivityOptions
                .makeSceneTransitionAnimation(this, v, "reveal");
        startActivity(intent, options.toBundle());
    } catch (Exception e) {
        // makeSceneTransitionAnimation not supported, maybe a check of SDK level is enough to avoid catching an error?
        Intent intent = new Intent(this, SearchActivity.class);
        startActivity(intent);
        e.printStackTrace();
    }
}

不幸的是,当前动画在动画期间会显示一个矩形。

怎么可能把它变成我们喜欢棒棒糖的美丽圆形画面?

感谢。

编辑:

我正在努力实现这一目标(除了颜色应该全屏,但你明白了......)): enter image description here

我真正得到的是:

enter image description here

1 个答案:

答案 0 :(得分:3)

好的,我以此为例:它工作正常:

Code on Github from saulmm

但是,.... 是的,这很简单并且工作正常,但我认为这不是实现效果的最有效方法。 为布局添加额外视图并使用可见性可能不是最佳方式。

实施George Mount解决方案时遇到了很多麻烦。 但是,由于此解决方案由Google的软件工程师编写,在Android UI工具包团队中工作,并且由其他Google工程师Alex建议,我想我应该花更多时间使用它,因为它不需要我布局中的额外视图...

第二个对我来说有点困难,但会继续努力。

无论如何,问题都解决了。