使用共享元素的过渡与ChangeImageTransform两种活动之间的动画的ImageView两种、元素、动画、ImageView

由网友(≒αи好勿念ゞ)分享简介:我想一个ImageView的动画在Android的大号preVIEW在Android的API级别21的两项活动之间的另一个位置。由于MoveImage已被删除,我用ChangeImageTransform"相反,但样本code。在文件不工作(分别动画两个图像)。< transitionSet的xmlns:机器人=...

我想一个ImageView的动画在Android的大号preVIEW在Android的API级别21的两项活动之间的另一个位置。由于MoveImage已被删除,我用ChangeImageTransform"相反,但样本code。在文件不工作(分别动画两个图像)。

 < transitionSet的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android>
    < changeImageTransform>
        <目标>
            <目标机器人:目标=@ ID / IVA/>
            <目标机器人:目标=@ ID / IVB/>
        < /目标>
    < / changeImageTransform>
< / transitionSet>
 

有没有工作的例子吗?谢谢!

解决方案

要进行两次活动有一个共同的元素之间的屏幕过渡动画, 你可以阅读这篇文章,并按照提到的步骤:

     打开窗口的内容转换在你的主题。   指定在样式共享元素的过渡。   定义您的转换为XML的资源。   分配一个共同的名字在这两个布局的Andr​​oid共享的元素:transitionName属性   使用ActivityOptions.makeSceneTransitionAnimation()方法。   

关于第三步骤,根据本documentation:

  PS の LOGO设计 制作Logo的无限创意

在与ChangeBounds组合,ChangeImageTransform允许改变大小,形状或ImageView.ScaleType流畅的动画内容ImageViews。

在RES /转换/ your_transition.xml应该是这样的:

 < transitionSet的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android>
    < changeBounds>
        <目标>
            <目标机器人:目标=@ ID / IVA/>
            <目标机器人:目标=@ ID / IVB/>
        < /目标>
    < / changeBounds>
    < changeImageTransform>
        <目标>
            <目标机器人:目标=@ ID / IVA/>
            <目标机器人:目标=@ ID / IVB/>
        < /目标>
    < / changeImageTransform>
< / transitionSet>
 

或者干脆像这样如果只IVA和IVB需要被激活:

 < transitionSet的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android>
    < changeBounds />
    < changeImageTransform />
< / transitionSet>
 

I am trying to animate one ImageView to another position between two activities in Android API level 21. Since "MoveImage" in Android L Preview has been removed, I use "ChangeImageTransform" instead, but the sample code in documents doesn't work out (the two images animated separately).

<transitionSet xmlns:android="http://schemas.android.com/apk/res/android">
    <changeImageTransform>
        <targets>
            <target android:targetId="@id/ivA" />
            <target android:targetId="@id/ivB" />
        </targets>
    </changeImageTransform>
</transitionSet>

Is there any working example? Thanks!

解决方案

To make a screen transition animation between two activities that have a shared element, you can read this article and follow the mentioned steps:

Enable window content transitions in your theme. Specify a shared elements transition in your style. Define your transition as an XML resource. Assign a common name to the shared elements in both layouts with the android:transitionName attribute. Use the ActivityOptions.makeSceneTransitionAnimation() method.

About the 3rd step, according to the documentation:

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

The res/transition/your_transition.xml should be like this:

<transitionSet xmlns:android="http://schemas.android.com/apk/res/android">
    <changeBounds>
        <targets>
            <target android:targetId="@id/ivA" />
            <target android:targetId="@id/ivB" />
        </targets>
    </changeBounds>
    <changeImageTransform>
        <targets>
            <target android:targetId="@id/ivA" />
            <target android:targetId="@id/ivB" />
        </targets>
    </changeImageTransform>
</transitionSet>

or simply like this if only ivA and ivB need to be animated:

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

阅读全文

相关推荐

最新文章