Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
270 views
Welcome To Ask or Share your Answers For Others

1 Answer

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!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...