
我已经知道如何在活动之间共享元素以及如何进行循环显示,但我正在努力按顺序完成所有事情!
这是我到目前为止的地方,效果并不是那么糟糕,但在圆形揭示(隐藏项目)之后,有一点时间才能启动意图.
我的项目:
<?xml version="1.0" enCoding="utf-8"?><androID.support.v7.Widget.CardVIEw xmlns:card_vIEw="http://schemas.androID.com/apk/res-auto" xmlns:androID="http://schemas.androID.com/apk/res/androID" androID:ID="@+ID/card_item" androID:layout_wIDth="match_parent" androID:layout_height="wrap_content" card_vIEw:cardUseCompatpadding="true" card_vIEw:cardCornerRadius="2dp"> <relativeLayout androID:ID="@+ID/secondary_back" androID:layout_wIDth="match_parent" androID:layout_height="200dp" androID:background="@color/colorPrimary" androID:visibility="gone"> </relativeLayout> <relativeLayout androID:layout_wIDth="match_parent" androID:layout_height="200dp" androID:visibility="visible"> <linearLayout androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:layout_centerHorizontal="true" androID:layout_centerVertical="true"> <de.hdodenhof.circleimagevIEw.circleimageVIEw xmlns:app="http://schemas.androID.com/apk/res-auto" androID:ID="@+ID/shared_element" androID:Transitionname="shared" androID:layout_wIDth="60dp" androID:layout_height="60dp" androID:src="@drawable/shared_color" androID:visibility="gone"/> </linearLayout> </relativeLayout> <relativeLayout androID:ID="@+ID/primary_back" androID:layout_wIDth="match_parent" androID:layout_height="200dp" androID:background="@drawable/ripple_background_rounded"> <linearLayout androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:layout_centerHorizontal="true" androID:layout_margintop="16dp"> <de.hdodenhof.circleimagevIEw.circleimageVIEw xmlns:app="http://schemas.androID.com/apk/res-auto" androID:ID="@+ID/card_image" androID:layout_wIDth="85dp" androID:layout_height="85dp" app:civ_border_wIDth="3dp" app:civ_border_color="@color/colorPrimary"/> </linearLayout> <TextVIEw androID:ID="@+ID/card_text" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:textSize="24sp" androID:textcolor="@androID:color/black" androID:paddingStart="16dp" androID:paddingEnd="16dp" androID:paddingtop="24dp" androID:paddingBottom="24dp" androID:layout_alignParentBottom="true"/> </relativeLayout></androID.support.v7.Widget.CardVIEw>
和我的功能,以启动一切:
private voID launchAnimation(VIEw v,final int position) { // prevIoUsly visible vIEw final VIEw myVIEw = v.findVIEwByID(R.ID.primary_back); final VIEw background = v.findVIEwByID(R.ID.secondary_back); // my shared element final circleimageVIEw sharedElement = (circleimageVIEw) v.findVIEwByID(R.ID.shared_element); // get the center for the clipPing circle int cx = myVIEw.getWIDth() / 2; int cy = myVIEw.getHeight() / 2; // get the initial radius for the clipPing circle float initialRadius = (float) Math.hypot(cx,cy); // create the animation (the final radius is zero) final Animator anim = VIEwAnimationUtils.createCircularReveal(background,cx,cy,initialRadius,0); // fade in background final Animation fadeIn = new AlphaAnimation(0,1); fadeIn.setInterpolator(new DecelerateInterpolator()); //add this fadeIn.setDuration(200); final Animation fadeOut = new AlphaAnimation(1,0); fadeOut.setInterpolator(new AccelerateInterpolator()); //and this fadeOut.setDuration(200); // make the vIEw invisible when the animation is done anim.addListener(new AnimatorListenerAdapter() { @OverrIDe public voID onAnimationStart(Animator animation) { super.onAnimationStart(animation); } @OverrIDe public voID onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); background.setVisibility(VIEw.GONE); Intent intent = new Intent(context,ResultActivity.class); // Pass data object in the bundle and populate details activity. intent.putExtra(ResultActivity.EXTRA_position,position); ActivityOptionsCompat options = ActivityOptionsCompat. makeSceneTransitionAnimation(activity,sharedElement,"shared"); activity.startActivity(intent,options.toBundle()); } }); background.setVisibility(VIEw.VISIBLE); background.startAnimation(fadeIn); myVIEw.startAnimation(fadeOut); fadeIn.setAnimationListener(new Animation.AnimationListener() { @OverrIDe public voID onAnimationStart(Animation animation) { anim.start(); } @OverrIDe public voID onAnimationEnd(Animation animation) { myVIEw.setVisibility(VIEw.GONE); sharedElement.setVisibility(VIEw.VISIBLE); } @OverrIDe public voID onAnimationRepeat(Animation animation) { } });} 如果有人知道如何简化这个动画会非常有用.非常感谢.
解决方法 对于那些可能想制作这种动画的人来说,我发现了一个关于这个确切过渡的 article.在本文的最后,有一个项目存档帮助我做了很多工作.
总结以上是内存溢出为你收集整理的android – 共享元素和循环显示全部内容,希望文章能够帮你解决android – 共享元素和循环显示所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)