Android的看法动画:用自身替换视图 [英] Android view animation: replacing view by itself

查看:87
本文介绍了Android的看法动画:用自身替换视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的Andr​​oid应用程序,我有创新的概念:用户可以浏览对象序列。相同的观点,当然,用于显示所有对象,只更新组件(文本,图像等)时,下一个对象是要显示

In my android app, I have a notion of "trails": a sequence of objects that the user can navigate. The same view, naturally, is used to display all objects, just updating components (texts, images, etc.) when the next object is to be shown.

现在,我想有生命物体之间的转换:当用户从一个对象下一个对象导航,我要使用的幻灯片动画由右至左(和其他方式)。问题是,我没有这两个视图之间进行动画 - 只有一个视图。因此,当我试图动画显示此视图(当一个对象被加载),可见视图中消失,我得到了一个空白页面 - 然后从右侧视图中的幻灯片

Now, I want to animate the transition between objects: when the user navigates from an object to the next object, I want to use the slide animation from right to left (and the other way around). The issue is that I don't have two views to animate between - only one view. Therefore when I try to animate displaying this view (when the next object is to be loaded), the visible view disappears, I get a blank screen - and then the view slides in from the right.

我要的反而是有现有视图滑出,并通过一个新的视图(但具有不同的内容相同的观点)被替换为从右侧滑入。

What I want instead is to have the existing view to slide out and be replaced by a new view (same View but with different content) to slide in from the right.

我应该如何去做?

推荐答案

该解决方案被证明是非常简单的:ViewPager。我公司提供PageAdapter,它返回两个相似的看法(相同的布局,不同的内容),并ViewPager负责剩下的照顾。如果我想禁用刷卡页面的变化,我不得不做的是延长ViewPager,覆盖onInterseptTouchListener并返回false。

The solution turned out to be very simple: ViewPager. I provide PageAdapter, which returns two similar views (same layout, different content) and ViewPager takes care of the rest. If I wanted to disable the swipe page changes, all I had to do is extend ViewPager, override onInterseptTouchListener and return false.

这篇关于Android的看法动画:用自身替换视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆