如何从库迁移到Horizo​​ntalScrollView&安培; ViewPager? [英] How to migrate from Gallery to HorizontalScrollView & ViewPager?

查看:131
本文介绍了如何从库迁移到Horizo​​ntalScrollView&安培; ViewPager?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要简单的控制,在Android 2.2及更高版本的图标选择。
画廊对我来说是更好的解决方案,但它是pcated德$ P $,我必须用 Horizo​​ntalScrollView ViewPager 代替。
但如何迁移容易吗?如何在这种情况下使用这个类和控制?我一直试图找到完整的例子为这个问题上,但我不能找到它。

I need simple control for icon choosing on Android 2.2 and higher.
Gallery was a better solution for me, but it is deprecated and I have to use HorizontalScrollView and ViewPager instead.
But how to migrate easy? How to use this classes and controls in this case? I've try to find complete example for this subject, but I can't find it.

推荐答案

此要点从戴维·史密斯显示了一种方法使用 ViewPager 有视觉效果非常类似于图库

This gist from Dave Smith shows a way to use ViewPager to have visual results very similar to a Gallery:

引述我的博客文章上显示多个页面的主题在一时间 ViewPager

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

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.

您可能还需要筛选这个Android的开发者线程其中有人指出了一个问题,这在较新的Andr​​oid版本。你需要禁用硬件加速由于 ViewPager <错误/ code>

You might also want to sift through this android-developers thread, where somebody pointed out an issue with this on newer Android versions. You need to disable hardware acceleration due to a bug in ViewPager.

这篇关于如何从库迁移到Horizo​​ntalScrollView&安培; ViewPager?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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