开发者

Get number of Home screens in 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 ther开发者_开发百科e anyway to get the number of home screen?

Thanks.


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!


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜