这部动画到底是怎么回事?

What the heck is going on with this animation?

我正在使用来自共享元素库的 makeSceneTransitionAnimation API 调用将折叠工具栏 header 中的图像共享到详细视图 activity。忽略 FAB 看起来不合适的地方,如果我能让它看起来更好,我打算将它们滑出动画的一部分。

看起来很可怕:https://youtu.be/Js91TAvwrV0

代码如下:

CollapsingToolbar Sender:

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public void LollipopTransition(View v) throws IOException {
    Log.d("The Jones Theory", "LollipopTransition...");
    ImageView imgFavorite = (ImageView) findViewById(R.id.header);
    final View nestedContent = findViewById(R.id.nested_content);
    hideView(nestedContent);
    startActivity(intent, ActivityOptions.makeSceneTransitionAnimation(PostSelectedActivity.this, imgFavorite, "photo_hero").toBundle());
}

DetailView Receiver:

getWindow().getEnterTransition().addListener(new Transition.TransitionListener() {
        @Override
        public void onTransitionStart(Transition transition) {
        }

        @Override
        public void onTransitionCancel(Transition transition) {
        }

        @Override
        public void onTransitionPause(Transition transition) {
        }

        @Override
        public void onTransitionResume(Transition transition) {
        }

        @Override
        public void onTransitionEnd(Transition transition) {
            getWindow().getEnterTransition().removeListener(this);

            // load the full version, crossfading from the thumbnail image
            Ion.with(photoView)
                    .crossfade(true)
                    .deepZoom()
                    .load(PostImage);

        }

我记得有过类似的问题。从文档的某些部分看来,changeImageTransform 应该足够了(而且我认为在某些版本中它确实看起来不错)但是尝试将 changeBounds 添加到您的 transitionSet here 以获得此:

<transitionSet xmlns:android="http://schemas.android.com/apk/res/android">
<changeImageTransform/>
<changeBounds/>
</transitionSet>

documentation for changeImageTransform 现在说

In combination with ChangeBounds, ChangeImageTransform allows ImageViews that change size, shape, or ImageView.ScaleType to animate contents smoothly.