Android AppWidget 是否仅限于特定尺寸?
我正在制作一个位于主屏幕上的 Android AppWidget。
用户的主屏幕空间很宝贵,所以我希望小部件很小。理想的尺寸是 2x1 单元格。
- 一些文档建议您可以使用任何您喜欢的尺寸?
- 但是 AppWidget 图形设计指南暗示 只有标准尺寸才是支持:4x1、3x3、2x2。
- 这是指可用的 PhotoShop 模板还是 Android 本身的限制?
- 我发现 2x1 小部件可以在我的实际设备 (HTC Wildfire) 上运行,但在模拟器上会扩展为 2x2。
- HTC 有自己的主屏幕的特殊实现,所以也许我的小部件只会在 HTC 设备上以 2x1 工作?
有没有办法创建 2x1 小部件,或者我应该使用标准尺寸?
我的小部件改编自 简单维基词典示例。
- 清单有
android:minWidth="146dip"
和android:minHeight="72dip"
。 - 有 RelativeLayout
android:layout_width="fill_parent"
和android:layout_height="wrap_content"
我刚刚开始使用 Android,所以如果这是一个愚蠢的问题,请提前道歉。 :)
I'm making an Android AppWidget to sit on the home screen.
The user's home screen space is precious, so I want the widget to be small. The ideal size would be 2x1 cells.
- Some documentation suggests you can have any size you like?
- But the AppWidget graphical design guidelines imply that only standard sizes are supported: 4x1, 3x3, 2x2.
- Does that refer to the available PhotoShop templates or is it a limitation of Android itself?
- I'm finding that a 2x1 widget works on my actual device (HTC Wildfire) but expands to 2x2 on the emulator.
- HTC have their own special implementation of the home screen, so maybe my widget will only work at 2x1 on HTC devices?
Is there any way to create a 2x1 widget, or should I use a standard size?
My widget was adapted from the Simple Wiktionary sample.
- The manifest has
android:minWidth="146dip"
andandroid:minHeight="72dip"
. - There's a RelativeLayout with
android:layout_width="fill_parent"
andandroid:layout_height="wrap_content"
I'm just starting with Android, so apologies in advance if this is a silly question. :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这绝对不是一个愚蠢的问题。
我的印象是 2x1 是合法尺寸,但我还没有尝试过该尺寸。
不同的主屏幕实现可能会以不同的方式解释尺寸,但我希望它们大体一致。
您可以尝试使用较小的
android:minHeight
值,看看是否需要一个新阈值来说服模拟器为您提供 2x1 应用程序小部件。话虽如此,使用 2x2 应用程序小部件可能会获得更一致的结果。It's definitely not a silly question.
I was under the impression that 2x1 was a legal size, but I have not tried one of that size.
Different home screen implementations might interpret the sizing differently, though I would hope that they would be generally consistent.
You could experiment with smaller
android:minHeight
values, to see if there is a new threshold you need to convince the emulator to give you a 2x1 app widget. That being said, you may have more consistent results with a 2x2 app widget.根据 appwidget design 页面,有效尺寸为
话虽这么说,我已经编写了 1x1 和 2x1 小部件,但没有听说过它们在任何地方都不起作用。
According to the appwidget design page, valid sizes are,
That being said, I've written 1x1 and 2x1 widgets and have not heard of them not working anywhere.