针对 BlackBerry 上的多种屏幕尺寸进行开发
Android 和 iOS 具有“密度独立像素”的概念,因此您的布局在不同密度和屏幕尺寸的设备上看起来相同。
到目前为止,我已经编写了使用像素手动间隔元素的代码(即我希望此按钮距屏幕左侧 10 个像素)。这在曲线上非常棒,但是当我将其加载到粗体上时,分辨率要高得多,因此 10 像素是一个小得多的物理空间。
BlackBerry 上多种屏幕尺寸的最佳实践是什么?有没有简单的方法来定义密度无关像素? RIM 似乎没有提供太多文档或 API 来让这一切变得简单。
Android and iOS have a concept of a "density independent pixel" so your layouts look the same on devices with different densities and screen sizes.
Up until now I've written code to manually space elements using pixels (i.e. I want this button to be 10 pixels from the left side of the screen). This is great on a Curve, but when I load it up on a Bold the resolution is much higher, so 10 pixels is a much smaller physical space.
What are the best practices for multiple screen sizes on BlackBerry? Is there any easy way to define a density independent pixel? RIM seems to not offer much in terms of documentation or APIs to make this easy.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
点是与密度无关的像素(具有良好的准确性)。
对于 BlackBerry,最相关的类是
net.rim.device.api.ui.Ui
,它定义了一个 UNITS_pt 常量(和一个 UNITS_px 常量),一个用于转换的convertSize
方法点和像素之间(因为图形上的操作采用像素而不是点)。对于 BlackBerry 应用程序来说,一种有用的方法是采用与字体大小相关的所有内容(以磅为单位定义) - 有一个
net.rim.device.api.ui.Font.derive
版本采用单位参数,可以轻松获取具有特定磅值的字体。当然,你不能认为任何事情都是理所当然的 - 用点来定义事物会让事情变得更容易,但是使用黑莓你会处理许多不同的像素密度和长宽比,所以要彻底测试,至少在模拟器上。
Points are density independent pixels (to a good degree of accuracy).
For BlackBerry, the most relevant class is
net.rim.device.api.ui.Ui
which defines a UNITS_pt constant (and a UNITS_px constant), aconvertSize
method to convert between points and pixels (since operations onGraphics
take pixels instead of points).A useful methodology for BlackBerry apps is to take everything in relation to your font sizes, which you define in points - there's a version of
net.rim.device.api.ui.Font.derive
that takes a units parameter and makes it easy to get fonts with a particular point size.Of course, you can't take anything for granted - defining things in points will make things easier, but with BlackBerry you deal with lots of different pixel densities and aspect ratios so test thoroughly, at least on the simulators.