- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
这个问题在这里已经有了答案:
Supporting multiple screens - Blackberry
(2 个回答)
7年前关闭。
我需要为黑莓应用程序设计 UI。此应用程序应支持多种黑莓分辨率。
一种方法是每次检查 screen_width 和 screen_height,并相应地从 res 文件夹中获取图像。有没有其他更有效或更好的方法来做到这一点?根据屏幕大小,我还需要对字体大小和文本执行相同的操作。
请帮我知道支持多种BB分辨率的标准方法
最佳答案
你可以试试,到目前为止我在我的应用程序中尝试过的没有任何问题。
Step 1:
Create a separate package like com.your_app_name.uiconfig which will contain an abstract class say ModelConfig and different classes for different resolutions like class BB83xxConfig for resolution 320x240 (width x height), class BB95xxConfig for resolution 360 x 480 (width x height).
Step 2:
ModelConfig class will provide the concrete implementation of the methods that will be common to all irrespective of the screen resolutions and the declaration of abstract methods whose concrete implementation will be provided in the respective classes based on the screen resolution.
Step 3: Make each and every class, that is implemented for particular resolution extend ModelConfig and provide concrete implementation of methods as per requirement.
Step 4: Use singleton pattern to get the instance of ModelConfig, so that it is intantiated only once and that instance is used throughout.
public abstract class ModelConfig {
private static ModelConfig modelConfig = null;
public static ModelConfig getConfig() {
if (modelConfig == null) {
if (DeviceInfo.getDeviceName().startsWith("83")) {
modelConfig = new BB83xxConfig();
} else if (DeviceInfo.getDeviceName().startsWith("85")) {
// 85xx also has 360 x 240 same as 83xx device
modelConfig = new BB83xxConfig();
} else if (DeviceInfo.getDeviceName().startsWith("89")) {
modelConfig = new BB89xxConfig();
} else if (DeviceInfo.getDeviceName().startsWith("90")) {
modelConfig = new BB90xxConfig();
} else if (DeviceInfo.getDeviceName().startsWith("95")) {
modelConfig = new BB95xxConfig();
} else if (DeviceInfo.getDeviceName().startsWith("96")) {
modelConfig = new BB96xxConfig();
} else if (DeviceInfo.getDeviceName().startsWith("97")) {
modelConfig = new BB97xxConfig();
} else if (DeviceInfo.getDeviceName().startsWith("99")) {
modelConfig = new BB99xxConfig();
} else if (DeviceInfo.getDeviceName().startsWith("98")) {
// 9800 also has 360 x 480 same as 95xx device
modelConfig = new BB95xxConfig();
}else {
modelConfig = new DefaultConfig();
}
}
return modelConfig;
}
// Font height for the default font used for the application.
public abstract int getApplicationFontHeight();
// Font height for the header label font.
public abstract int getHeaderLabelFontHeight();
// Height for the coloured background of Header.
public abstract int getHeaderBarHeight();
// Height for the individual row in the list.
public abstract int getCustomListRowHeight();
public abstract int getStandardButtonWidth();
public abstract int getStandardLabelWidth();
public abstract int getTitleFontHeight();
// get Background colour for Header.
public int getHeaderBackgroundColor() {
return 0x26406D;
}
// get Bitmap showing Right Arrow.
public Bitmap getBitmapRightArrow() {
return Bitmap.getBitmapResource("right_arrow.png");
}
// get Bitmap rounded black border for editfield.
public Bitmap getBitmapRoundedBorderEdit(){
return Bitmap.getBitmapResource("rounded_border_black.png");
}
// get Bitmap rounded gray border and white background.
public Bitmap getBtmpRoundedBorderBgrnd(){
return Bitmap.getBitmapResource("rounded_border_grey.png");
}
// get Bitmap rounded gray border and white background.
public Bitmap getBtmpTransparentBgrnd(){
return Bitmap.getBitmapResource("img_transparent_background.png");
}
// get Bitmap showing down Arrow.
public Bitmap getBitmapDownArrow(){
return Bitmap.getBitmapResource("down_arrow.png");
}
}
/*
* Common resolution 360*480 pixels (width x height)
*/
public class BB95xxConfig extends ModelConfig {
// Font height for the default font used for the application.
// returns Desired height in pixels.
public int getApplicationFontHeight() {
return 18;
}
// Font height for the header label font.
// returns Desired height in pixels.
public int getHeaderLabelFontHeight() {
return 20;
}
// returns Desired height in pixels for the header background.
public int getHeaderBarHeight() {
return Display.getHeight() / 10;
}
public int getCustomListRowHeight() {
return 50;
}
public int getStandardButtonWidth() {
return 108;
}
public int getStandardLabelWidth() {
return 150;
}
public int getTitleFontHeight() {
return 11;
}
}
关于user-interface - 黑莓支持多种分辨率,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18718580/
我想创建后台应用程序,它将监听哪些应用程序已启动以及哪些应用程序移至前台。 请回复 如果问题不清楚会再次解释。 谢谢 最佳答案 这是你可以做的: 使用 ApplicationManager.getFo
下午好。 我开始用 java 和 blackberry 编程。 我正在开发一个带有三个窗口的应用程序,我将显示有关设备的基本信息,这些窗口已经完成并可以工作。 我需要创建一个在后台运行的进程,这个进程
如何翻转 Bitmap上下翻转? (我需要这个来在另一个程序中加载 OpenGL 纹理)。 这是我失败的尝试: stripe.png(由 Pitr@OpenClipart 提供): 翻转.java:
从 Internet 上可用于签署 BB 应用程序的内容来看,我可以猜测我们只需要用于签署应用程序的 .cod 文件,而不需要源代码。 有人可以确认这一点吗? 最佳答案 编译代码时会自动生成 .cod
我想访问闹钟。在我的应用程序中,我已成功访问日历并设置了约会,但我如何访问闹钟。请帮我。以下是我的代码 public class Alarm { private Event event;
作为应用程序的一部分,我们将在设备上的“file:///store/home/user/”位置创建一个文件 myApp.cfg。设备上的加密已启用。因此,myApp.cfg 被重命名为 myApp.c
我需要制作一个包含可点击号码的标签,这样当用户点击标签时,就会调用电话号码(或向用户显示调用电话的选项)。当我现在点击标签时,我只得到一个工具提示类型的菜单,其中包含复制数字的选项... privat
我有兴趣在我的 BlackBerry 应用程序中添加一个可拖动的 slider 。 我想知道 BlackBerry API 中是否有类似的东西,或者是否有人做过类似的东西! 最佳答案 有一个Gauge
最初开发黑莓应用的时候,并没有太在意能够支持多种屏幕分辨率。所以,我最终得到了在 320*240 分辨率下运行良好但在其他屏幕上完全困惑的代码。 我该如何解决这个问题?或者一般来说,如果不为每个资源构
我创建了一个这样的静态函数。 public static Bitmap Bitmap(String path) { Bitmap bitmap = Bitmap .ge
我需要 BlackBerry 本地化方面的帮助。我在 http://na.blackberry.com/eng/developers/resources/developer_labs.jsp#tab_
我创建了一个 RichTextField 我想让它只允许整数值。我怎样才能做到这一点? 最佳答案 你可以尝试这样的事情: public class MyRichTextField extends Ri
在 BlackBerry 平台中,我想知道是否可以/如何执行以下操作: 检索通话记录(我对来电记录特别感兴趣); 删除特定的通话记录; 最佳答案 要检索电话日志,请查看 PhoneCallLog cl
我想知道我们是否可以调整图像大小。假设我们要在黑莓屏幕上绘制一个实际尺寸为200x200且尺寸为100 x 100的图像。 谢谢 最佳答案 只是一种选择: BlackBerry - draw imag
黑莓 JDE 不包括 java.util.ArrayList ,即使它知道 java.util ?那是怎么回事? BB 有对应的类(class)吗?我不想使用数组,真的,因为我要处理的对象数量未知。为
我想使用 graphics.drawLine 方法在 drawListRow 中的黑莓 Listfield 中添加一个分隔符,但下面根本没有绘制线是我正在使用的来源 drawListRow(ListF
我正在为Blackberry设备开发一个应用程序。这个程序包含一个数据库。由于该API是在最新的API版本上提供的,因此我决定使用SQLite。 我遵循了随处都可以找到的所有示例,但是无论发生什么情况
我已将 Blackberry 4.6.0 应用程序移植到 4.7.0 上的 Storm。除了我试图控制的触摸事件之外,一切都运行良好。我在下面的方法中捕获触摸事件,它按预期执行,但问题是在我的 tou
我正在为 BB 开发一个项目。该应用程序与网络一起工作,并通过 HTTP 发送/接收数据。现在我使用队列和队列管理器。管理器从一个后台线程开始,并在 while (true) 循环中工作,检查队列中是
我想在黑莓中合并两个图像。一张图像是大图像,另一张图像是小图像。小图像的位置将由开发人员定义。有哪些可能的方法? 最佳答案 您可以使用 Graphics 类以不同的偏移量在其上绘制多个位图。查看Gra
我是一名优秀的程序员,十分优秀!