开发者

j2me how to implement landscape orientation in application if device doesn't support it by default

开发者 https://www.devze.com 2023-02-23 18:02 出处:网络
I have nokia 2323c device, and i want display my application in landscape mode. I tried to add Nokia-MIDlet-App-Orientation : landscape to JAD, but it doesn\'t work for me.

I have nokia 2323c device, and i want display my application in landscape mode.

I tried to add Nokia-MIDlet-App-Orientation : landscape to JAD, but it doesn't work for me.

Can it be done?

开发者_StackOverflow社区

Thanks.


That handset looks like a regular candybar style phone, that no user would normally use in landscape mode...

I bet it won't have a sensor to detect and inform you when the user has turned the device in to landscape mode.

But assuming that's not what you want, and you just want to draw everything in landscape mode by default, yes you can do it... as long as your app uses Canvas-based UI and not Form-based.

You need to wrap the Graphics drawing functions with your own. For example, drawRect(x, y, w, h), to make this work in Landscape mode you'd implement it something like as follows:

void drawRectLandscape(Canvas c, Graphics g, int x, int y, int w, int h) {
    int newX = c.getWidth() - y - h;
    int newY = x;
    int newW = h;
    int newH = w;
    g.drawRect(newX, newY, newW, newH);
}

You'd also need to make use of the Sprite class's text drawing functions.

0

精彩评论

暂无评论...
验证码 换一张
取 消