我正在努力在两个活动之间在android中创建一个共享元素转换,这些活动可以扩展图层列表背景,就像它是一个坚实的背景一样。
目前的情况如下: https://www.youtube.com/watch?v=BFbyf8-sPdw
背景被缩放为两个不同的对象。
后台xml:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:bottom="80dp"
android:id="@+id/card_background_top">
<shape
android:shape="rectangle" >
<gradient
android:type="linear"
android:startColor="@color/card_ocean_blue_start"
android:endColor="@color/card_ocean_blue_end"
android:angle="45" />
<corners
android:topLeftRadius="5dp"
android:topRightRadius="5dp" />
</shape>
</item>
<item android:top="120dp">
<shape>
<solid android:color="@color/white"
android:height="100dp"/>
<corners
android:bottomRightRadius="5dp"
android:bottomLeftRadius="5dp"/>
</shape>
</item>
</layer-list>
像这样设置动画:
if (Build.VERSION.SDK_INT >= 21) {
Transition transition = TransitionInflater.from(this).inflateTransition(R.transition.card_shared_elemement_transition);
getWindow().setSharedElementEnterTransition(transition);
}
过渡看起来像这样:
<?xml version="1.0" encoding="utf-8"?>
<transitionSet xmlns:android="http://schemas.android.com/apk/res/android"
android:transitionOrdering="together"
android:duration="400">
<changeBounds/>
<changeImageTransform/>
<fade
android:fadingMode="fade_in"
android:startDelay="200">
</fade>
</transitionSet>