开发用于黑莓手机上的多个屏幕大小 [英] Developing for multiple screen sizes on BlackBerry

查看:183
本文介绍了开发用于黑莓手机上的多个屏幕大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Android和iOS有一个独立的密度像素这样你的布局看起来一样对不同密度和屏幕尺寸设备的概念。

到现在为止,我已经写了code手动使用像素的空间元素(即我想这个按钮是从屏幕的左侧10像素)。这对一个曲线是伟大的,但是当我加载它在一个大胆的分辨率要高得多,因此,10个像素是一个更小的物理空间。

什么是黑莓手机上的多个屏幕大小的最佳实践?有没有简单的方法来定义密度独立的像素? RIM似乎没有提供太多的文档条款或API来使这个容易。


解决方案

点是密度独立像素(有一个良好的精确度)。

有关黑莓,最相关的类是 net.rim.device.api.ui.Ui 它定义了一个UNITS_pt常数(和UNITS_px常数),一个 convertSize 的方法来分,像素之间的转换(因为操作上的图形取像素,而不是点)。

黑莓应用程序一个有用的方法就是把有关的一切你的字体大小,您可以在点定义 - 有 net.rim.device.api.ui.Font.derive <的一个版本/ code>带有一个单位参数,可以很容易地获取字体与特定点的大小。

当然,你不能想当然任何东西 - 在点确定的事情会使事情变得更容易,但黑莓你处理很多不同的像素密度和纵横比如此彻底的测试,至少在模拟器

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.

解决方案

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), a convertSize method to convert between points and pixels (since operations on Graphics 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.

这篇关于开发用于黑莓手机上的多个屏幕大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆