Android的视差 - offsetPixel [英] Android Parallax - offsetPixel

查看:245
本文介绍了Android的视差 - offsetPixel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想设计一个驻留在ViewPager内部的复杂parallaxing动画。动画使用onPageScrolled函数的offsetPixel来计算图像中的位置。
然而,这种做法引起了很多的问题,因为如果快速滚动可跳过offsetPixel(例如:1到123到250到251),当缓慢它过于敏感使动画显得心有余悸。

I am trying to design a complicated parallaxing animation that resides inside a ViewPager. The animation uses onPageScrolled function's offsetPixel to calculate the position of the images. However this approach is causing a lot of problems due to the offsetPixel if scrolled fast can skip (ex: 1 to 123 to 250 to 251) and when slow it's too sensitive so the animation seems jittery.

有没有更好的方法来计算,除了offsetPixels屏幕的位置。如果是这样,任何人都可以请帮我指点迷津。将AP preciate非常喜欢!

Is there a better way to calculate the position of the screen besides offsetPixels. If so, can anyone please help me figure it out. Would appreciate it very much!

感谢您。

推荐答案

好吧,我不知道到底,如果一个页面中必须有视差效果,还是它必须被改变德过渡之间的视差效果页。

Well, I don't know exactly if one of the pages has to have the parallax effect, or it has to been a parallax effect between de transition of changing pages.

我开发了一个小型图书馆,使第二个, https://github.com/xgc1986/ParallaxPagerLibrary

I developed a small library to make the second one, https://github.com/xgc1986/ParallaxPagerLibrary

演示:视差演示

这与浏览图书馆工作时,你可以用它与imageViews有效果。

This library work with Views, the you can use it with imageViews to have the effect.

要做到这一点,我不使用去onPageScrolled功能,基本上那你就没有允许开发者再使用此侦听器,则解决了我实现PageTransformer的子

To do that I don't use de onPageScrolled function, basically then you don't permit to the developer to use this listener anymore, the to solve that I implemented a child of PageTransformer

这篇关于Android的视差 - offsetPixel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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