获取 Android 中主屏幕的数量?
我正在为 Android 制作动态壁纸,我希望它随着用户滚动主屏幕而滚动。我可以做到这一点,但在某些手机上,用户可以选择主屏幕的数量。有没有办法获取主屏幕的数量?
谢谢。
I'm making a Live wallpaper for Android, and I want it scroll as user scroll the home screen. I can do that, but on some phones, user can choose the number of home screen. Is there anyway to get the number of home screen?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
实际上有一种方法可以知道主屏幕的数量。 “onOffsetsChanged”调用为该海豚提供参数:float xOffset 和 float xOffsetStep。
xOffset 从 0 到 1,xOffsetStep 表示每个主屏幕的步长。因此,如果您将主屏幕配置为 6 个“桌面”,xOffsetStep 将为 0.2。
因此,检查屏幕数量的最终方法必须在该调用中完成(默认情况下它应始终为 1),然后: (1/xOffsetStep) + 1。
希望它有帮助!
There is actually a way to know the number of home screens. The 'onOffsetsChanged' call provides to arguments for that porpouse: float xOffset and float xOffsetStep.
xOffset goes from 0 to 1 and xOffsetStep represents the step size for each home scree. So if you configure your home screen with 6 'desktops' xOffsetStep would be 0.2.
So the final way to check the number of screens must be done in that call (by default it sould be always 1) and then: (1/xOffsetStep) + 1.
Hope it helps!
有许多“主屏幕”应用程序,包括但不限于每个品牌固件附带的应用程序。为此,您需要添加所有市场启动器,例如 Go Launcher、Launcher Pro 等。没有标准化的方法来实现启动器,因此很难找到所有可能的替代方案。
大多数启动器确实有一个内置选项可以在每个屏幕上滚动壁纸,尽管我无法告诉您它对于动态壁纸的效果如何。
There are many "home screen" apps, including, but not limited to, the ones that ship with every branded firmware. To that, you need to add all the market launchers, such as Go Launcher, Launcher Pro, etc. There is no standardised way to implement a launcher, so it will be quite difficult to find all the possible alternatives.
Most of the launchers do have a built-in option to scroll the wallpaper with every screen, although I can't tell you how well it works for live wallpapers.