Android 主屏幕数量
在开发动态壁纸并在 HTC Desire HD 上进行测试时,HTC Desire HD 有 7 个主屏幕(这意味着您可以从主主屏幕向左滚动 3 次,从主主屏幕向右滚动 3 次),我想知道这是否适用于每个 Android 设备都有吗?
如果没有,我如何访问这个主屏幕计数?
while developing a live wallpaper 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我有一个解决方法。当你开发动态壁纸时,在你自己的
WallpaperService
类中,你可以重写这个方法:public void onOffsetsChanged(float xOffset, float yOffset,float xOffsetStep, float yOffsetStep, int xPixelOffset,int yPixelOffset )
。当您滑动并拖动主屏幕时,系统将调用此方法。通过这种方法,您可以知道有多少个主屏幕,还可以识别当前主屏幕在哪里。
即,我的设备是 Moto Defy,它有 7 个主屏幕。当我从最左边的 homecrren 滑动到最右边时,
xOffset
从 0、0.16666、0.33333、0.5... 更改为 1。所以你看,两个直接xOffset
之间的差异> 是 0.16666=1/(主屏幕计数-1)。这只是xOffsetStep
的参数。结论:主屏幕计数=1/xOffsetStep+1。
我刚刚在我自己的 Defy 和模拟器(3 个主屏幕)上测试了这个方法,并发现了这个。 SDK文档中并没有详细解释该方法。请告诉我这是否适合您。谢谢。
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 immediatexOffset
is 0.16666=1/(homescreen count-1). This is just the parameter ofxOffsetStep
.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 个主屏幕绝对不是默认设置,Nexus One 只有 5 个主屏幕。这取决于安装的主屏幕应用程序。在 HTC 设备上,默认为“Sense”,支持 7 个主屏幕。原生 Android 主屏幕仅支持 5 个,其他可能支持无限个主屏幕。用户可以自行更换这些应用程序,因此不依赖于设备。
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.
就其价值而言,Motoblur(Droid X / X2 等)使用 7 个主屏幕。中心,两边+3。
For what its worth, Motoblur (Droid X / X2 etc) uses 7 home screens. Center, +3 either side.
Cyanogenmod 7 支持可变数量的主屏幕,因此一种尺寸的屏幕数量可能与另一种尺寸不同。
另外我可以随时更改数字并添加新数字,因此它并不总是恒定的
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