首页 > 解决方案 > 来自视图寻呼机共享元素的图像视图错误退出过渡

问题描述

我正在尝试制作一个流畅而漂亮的动画,但我遇到了这个问题:

https://streamable.com/09yjl

第一个 imageView 屏幕有 scaleType="centerCrop" 我认为这是问题所在。修复退出动画缩放的任何解决方案?

我使用以下代码打开 fullScreenActivity:

imageView.setOnClickListener(view1 -> {
    ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation((Activity) context, view1, "itemImageTransition");
    startActivity(new Intent(context, FullScreenImageActivity.class), options.toBundle());
});

和 viewpager 布局是

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">

<ImageView
    android:id="@+id/image"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="center"
    android:adjustViewBounds="true"
    android:scaleType="centerCrop"
    android:transitionName="itemImageTransition" />

全屏布局是

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">

<it.tcconsulting.cyclone.utils.TouchImageView
    android:id="@+id/imageView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:transitionName="itemImageTransition" />

标签: androidandroid-layoutshared-element-transition

解决方案


推荐阅读