android– 控制共享元素动画中的特定元素

android– 控制共享元素动画中的特定元素,第1张

概述在我的应用程序中,我有一个看起来像这样的共享元素<FrameLayoutandroid:id="@+id/container"android:layout_width="wrap_content"android:layout_height="wrap_content"><TextViewandroid:id="@+iditle"

在我的应用程序中,我有一个看起来像这样的共享元素

 <FrameLayout    androID:ID="@+ID/container"    androID:layout_wIDth="wrap_content"    androID:layout_height="wrap_content">    <TextVIEw        androID:ID="@+ID/Title"        androID:layout_margin="16dp"        androID:text="Title"        androID:layout_wIDth="wrap_content"        androID:layout_height="wrap_content"/>    <ImageVIEw        androID:ID="@+ID/image"        androID:src="@drawable/hero_image"        androID:layout_wIDth="wrap_content"        androID:layout_height="wrap_content"/></FrameLayout>

在我的活动中,我将图像标记为共享元素,因此图像转换为下一个活动.但是,我希望在图像转换之前淡出标题.看起来我应该能够通过使用setSharedElementExitTransition()并将标题设置为目标来实现这一点,但无论我尝试什么,该动画似乎都不起作用,并且过渡图像是在快照标题上绘制的.

我已经阅读了乔治山的https://halfthought.wordpress.com/2014/12/08/what-are-all-these-dang-transitions/并在SO上看了他的优秀答案,但我只需要更多的帮助:)

解决方法:

这是如何使基础工作,假设在标题视图上调用setTransitionname(“text”)

>在活动A中设置正确的共享元素退出动画:

getwindow().setSharedElementExitTransition(new TransitionSet().            addTransition(new Fade().addTarget("text"));

>调用startActivity()后,使用setVisibility(VIEw.INVISIBLE)更改标题文本视图的可见性.这是使淡入淡出工作所必需的.

将视图设置为INVISIBLE是我缺少的必要步骤,我还有一个窗口退出动画集.但是,我应该使用Window.setReturnTransition()设置窗口返回动画.

总结

以上是内存溢出为你收集整理的android – 控制共享元素动画中的特定元素全部内容,希望文章能够帮你解决android – 控制共享元素动画中的特定元素所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://www.54852.com/web/1119164.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-29
下一篇2022-05-29

发表评论

登录后才能评论

评论列表(0条)

    保存