gpt4 book ai didi

user-interface - 黑莓支持多种分辨率

转载 作者:行者123 更新时间:2023-12-04 04:42:17 25 4
gpt4 key购买 nike

这个问题在这里已经有了答案:





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.



ModelConfig.java(只是一个示例)
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");
}

}

BB95xxConfig.java(只是一个示例)
/*
* 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com