Android homescreen count
while developing a live wallpape开发者_如何转开发r and testing on a HTC Desire HD, which has 7 homescreens (meaning you can scroll 3 times to the left from the main homescreen and 3 times to the right from the main homescreen), I was wondering if this applies to every Android device out there?
If not, how can I access this homescreen count?
I have a workaround. When you develop a live wallpaper, in your own WallpaperService
class, you can override this method: public void onOffsetsChanged(float xOffset, float yOffset,float xOffsetStep, float yOffsetStep, int xPixelOffset,int yPixelOffset)
.
The system will call this method when you swipe and drag you homescreen. By this method, you can know how many homescreens there are, and you can also identify where the current homescrren is.
I.e, my device is Moto Defy, and it has 7 homescreens. When I swipe from the leftmost homescrren to the rightmost, xOffset
changes from 0, 0.16666, 0.33333,0.5... to 1. So you see, the difference between two immediate xOffset
is 0.16666=1/(homescreen count-1). This is just the parameter of xOffsetStep
.
Conclusion: homescreen count=1/xOffsetStep+1.
I just tested this method on my own Defy and an emulator(3 homescreens) and found this. The SDK document doesn't explain this method in details. Please tell me if this works for you. Thanks.
7 homescreens is defintivitely not the default, the Nexus One only got 5 homescreens. It depends on the Homescreen Application which is installed. On HTCs devices, this is "Sense" by default which supports 7 homescreens. The stock android Homescreen only supports 5, others might support infinite homescreens. The user can replace these applications on its own, so its not device-dependend.
For what its worth, Motoblur (Droid X / X2 etc) uses 7 home screens. Center, +3 either side.
Cyanogenmod 7 supports variable number of homescreens, so the number of screens on one size may not be the same as on another.
ALSO I can change the number and add new ones whenever I like, so its not always going to be constant
精彩评论