如何获取垂直和水平像素数?
我想显示一个带有方法签名的对话框 show(int top, int Bottom, int left, int right, boolean includeTitle)
我想将此对话框放置在屏幕中央。所以我想知道屏幕垂直方向的总像素数和屏幕水平方向的总像素数。
如何实现这一目标?
I want to show a Dialog with the method signature show(int top, int bottom, int left, int right, boolean includeTitle)
I want to place this Dialog in the center of the screen. So I want to know the total number of pixels of the screen vertically and the total number of pixels of the screen horizontally.
How to achieve that ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您正在寻找在 LWUIT 中为您提供这些维度的方法,那么
您获得对 Display
Display.getInstance()
的引用
然后你可以调用 getDisplayHeight() 或 getDisplayWidth();
但如果你想使用 MIDP 类,你必须获得对 Display
的引用
通过调用
Display.getDisplay(Midlet instance)
然后获取对的引用
current Displayable
getCurrent()
,然后您可以调用getWidth()
或getHeight()
。If you're looking for the methods that give you these dimensions in LWUIT then
you obtain a reference to the Display
Display.getInstance()
then you can call getDisplayHeight() or getDisplayWidth();
but if you want to use MIDP classes you have to get a reference to the Display
by calling
Display.getDisplay(Midlet instance)
and then getting a reference to thecurrent Displayable
getCurrent()
and then you can callgetWidth()
orgetHeight()
.