轻扫回到像Pinterest的或的tumblrPinterest、tumblr

2023-09-04 07:45:09 作者:烂人

是否有人有一个想法如何Pinterest的或的tumblr实施有刷回的方法。

Does anybody has an idea how Pinterest or Tumblr has implemented there "swipe back" method.

即。在Pinterest的,你可以点击的新闻提要一个职位。比起 DetailActivity 启动并显示信息为选定的职位。比你能preSS的后退按钮返回到新闻源活动,或者你可以刷卡(详情活动)向左回来新闻源活动。

i.e. on Pinterest you can click on a post on the news feed. Than the DetailActivity is started and displays the details for the selected post. Than you can press the back button to return to the news feed activity, or you can swipe (the details activity) to the left to come back to the news feed activity.

视频: http://youtu.be/eVcSCWetnTA

通常情况下,我会用 overridePendingTransition(),而 overridePendingTransition()需要动画(资源ID喜欢 R.anim.foo )。 Pinterest的和Tumblr启动动画仅当用户做一个扫掠姿态。它们还支持某种根据手指移动一帧动画帧。因此,他们跟踪的手指移动的距离和动画过渡到相应的百分比值。

Normally I would use overridePendingTransition(), but overridePendingTransition() takes animations (Resource ids like R.anim.foo). Pinterest and Tumblr start the animation only if the user do a swipe gesture. They also support some kind of "frame by frame animation" according the fingers move. So they track the distance of the finger move and animate the transition to the corresponding percentage value.

我知道如何使用一个真正的Java动画/ AnimatorSet对象与 FragmentTransaction 动画片段更换。随着片段我要重写 onCreateAnimator(),但我不知道如何实现类似与活动。是否有一个 onCreateAnimator()(或类似的东西)的活动?也不知过了刷卡的行为,因为它没有启动动画的权利,但更多的是一步一个窗口/活动/片段的一步财产changement或任何...

I know how to use a "real java" Animation / AnimatorSet Object with FragmentTransaction to animate a fragment replacement. With fragments I have to override onCreateAnimator(), but I have no clue how to implement something like that with Activities. Is there a onCreateAnimator() (or something similar) for Activities? Also not sure how to swipe behaviour, since its not starting the animation right now, but more a step by step property changement of the Window / Activity/ Fragment or whatever ...

有什么建议?

编辑: 我已经找到了Pinterest的应用程序的视频在YouTube上: http://youtu.be/eVcSCWetnTA 那是什么我想要实现。

I have found a video of the pinterest app at youtube: http://youtu.be/eVcSCWetnTA Thats what I want to implement.

我想Pinterest的正与片段和 onCreateAnimator()实现刷回。 由于我的应用程序早已片段和ChildFragments在活动这将是对我来说容易得多,如果我能实现,对于活动。

I guess Pinterest is working with Fragments and onCreateAnimator() to achieve the "swipe back". Since my App has already Fragment and ChildFragments in a activity it would be so much easier for me if I could implement that for Activities.

再一次:我知道如何检测滑动手势,并且那不是我要求的。观看YouTube视频: http://youtu.be/eVcSCWetnTA

Once more: I know how to detect swipe gestures and thats not what I'm asking for. Watch the youtube video: http://youtu.be/eVcSCWetnTA

更新: 我创建了一个小图书馆,里面有不完全像Pinterest的或Tumblrs执行相同的行为,但是,对于我的应用程序,这似乎给了我一个很好的解决方案: https://github.com/sockeqwe/SwipeBack?source=c

UPDATE: I have created a little library, which has not exactly the same behavior like Pinterest or Tumblrs implementation, however for my apps this seems to me a good solution: https://github.com/sockeqwe/SwipeBack?source=c

推荐答案

所以我想我找到了解决方案,通过我自己:

So I guess I found the solution by my self:

首先: Pinterest的确实使用了ViewPager具有自定义页面的变压器像@frozenkoi在答复提到。你可以看到在Pinterest的应用程序的视图寻呼机的oversroll边缘效应。

First of all: Pinterest indeed uses a ViewPager with a custom Page Transformer like @frozenkoi has mentioned in his answer. You can see the oversroll edge effect of the view pager in the pinterest app.

@Amit Gupta还指出,让活动幻灯片库。它的pretty的是同一个概念等的各种导航抽屉不和也套主题为半透明。它们滑动的布局。但是,那不正是我一直在寻找,因为它滑动在顶到右边,不是简单地调用完成()。但是下方活动将不被动画在

@Amit Gupta has pointed to library that let the activity slide. Its pretty the same concept like various Navigation drawers does and sets also the theme to translucent. They slide the layout. But thats not exactly what I was looking for, because it slides the top activity to the right and than simply calls finish(). But the underneath activity will not be animated in.

解决的办法是(我想这是是的tumblr所做的)来写你自己的动画与动画对象和动画它一步一步来。 这可以通过 ActivityOptions 来完成。 在我看来,这将是解决方案。

The solution is (and I guess this is was Tumblr does) to write your very own Animation with Animation Objects and animate it step by step. This can be done with ActivityOptions. In my opinion this will be the solution.