使用onOffsetsChanged()来获取主屏幕滑动方向 [英] using onOffsetsChanged() to get home screen swipe direction

查看:763
本文介绍了使用onOffsetsChanged()来获取主屏幕滑动方向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的工作我的动态壁纸,我希望它滚动在屏幕就像一个普通壁纸一样。我知道我需要使用onOffsetsChanged(),但参数会告诉我的方向的主屏幕被刷?好像xOffset总是返回正值,无论哪种方式,屏幕幻灯片。

I'm working on my Live Wallpaper and I want it to scroll with the screen like a normal wallpaper does. I know I need to use onOffsetsChanged() but which parameter will tell me the direction that the home screen is being swiped? It seems like xOffset always returns a positive value no matter which way the screen slides.

感谢你。

推荐答案

方向本身并不能帮助你:你需要知道确切的偏移,因为用户可能已跃升几个屏幕一次(使用弹出如最多显示迷你版本的所有主屏幕的)。

The direction alone will not help you: you need to know the exact offset, because the user may have jumped several screens at once (e.g. by using a pop-up that displays mini-versions of all the home screens).

一般来说,要保存你在onOffsetsChanged得到xPixel值,然后用这个翻译画布。

Generally speaking, you want to save the xPixel value you get in onOffsetsChanged, then use this to translate your canvas.

请参阅我的两个答案如下:
<一href="http://stackoverflow.com/questions/6573451/onoffsetschanged-move-bitmap/6574649">onOffsetsChanged:将位图
Android的动态壁纸的重新调整

See my two answers below:
onOffsetsChanged: move Bitmap
android live wallpaper rescaling

这篇关于使用onOffsetsChanged()来获取主屏幕滑动方向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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