简体   繁体   中英

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

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM