ViewPager用previous和下页的边界 [英] ViewPager with previous and next page boundaries

查看:205
本文介绍了ViewPager用previous和下页的边界的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我设计具有多页的视图。我想了previous和下一页的边缘是显示如下图所示,并实现2手指轻扫在页面之间切换。

I'm designing a view with multiple pages. I want edges of previous and next pages to be show like below and implement a 2 finger swipe to switch between pages.

我试图用 ViewPager 负页边距的建议<一href="http://stackoverflow.com/questions/7725045/android-viewpager-with-$p$pvious-and-next-pages-visible">here但是这仅示出了一个屏幕上的边缘,而不是同时在两个

I tried using ViewPager with negative page margin as suggested here but that only shows one of the edges on the screen, not both simultaneously.

另外,有什么办法可以定位我的屏幕外视图部分,然后动画它给它一个 ViewPager 键入效果。

Alternatively, is there any way i can position part of my view outside screen and then animate it giving it a ViewPager type effect.

我应该怎么做呢?谢谢!

How should I go about it ? Thanks !

推荐答案

关于这个问题的一篇博客文章:

第三种方法来自戴维·史密斯合着了广受好评的书的Andr​​oid食谱。他去了一个完全不同的方向,使用自定义的容器,残疾儿童裁剪显示多个页面的时间。

The third approach comes from Dave Smith, co-author of the well-regarded book Android Recipes. He went in a very different direction, using a custom container that disabled children clipping to show more than one page at a time.

公布样品code 显示操作整个事情。他的容器( com.example.pagercontainer.PagerContainer )会将 ViewPager 键,通话 setClipChildren(假); 本身,所以尽管 ViewPager 专注于一个选定的页面上,有超越 ViewPager 界限仍清晰可见,只要他们在 PagerContainer 适合。通过定径 ViewPager 来比 PagerContainer ViewPager 罐大小的页面,这种规模,留有余地其他页面待观察。 PagerContainer ,不过,需要帮忙,未免有触摸事件,如 ViewPager 将只处理刷卡事件自己可视范围,忽略可见双方的任何页面。

His published sample code shows the whole thing in action. His container (com.example.pagercontainer.PagerContainer) wraps the ViewPager and calls setClipChildren(false); on itself, so even though the ViewPager is focused on one selected page, other pages that have coordinates beyond the ViewPager bounds are still visible, so long as they fit within the PagerContainer. By sizing the ViewPager to be smaller than the PagerContainer, the ViewPager can size its pages to that size, leaving room for other pages to be seen. PagerContainer, though, needs to help out a bit with touch events, as ViewPager will only handle swipe events on its own visible bounds, ignoring any pages visible to the sides.

这篇关于ViewPager用previous和下页的边界的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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