views:

31

answers:

1

How can I have a portrait-oriented menu in my lanscape-oriented view in Android?Hi,

I'm building an application with some items that must be landscape-oriented. Everything else (menu, view for editing the item, list of item...) should change orientation according to the orientation of the device. To do that I set android:screenOrientation="landscape" in the AndroidManifest.xml for the activity showing my items. Now, how can I create a portrait-oriented menu for that activity?

I'm also wondering if setting the screen orientation of the activity is the only way? Isn't it possible to set the screenOrientation for each view?

Thanks

Jul

+1  A: 

Now, how can I create a portrait-oriented menu for that activity?

Draw it yourself using Canvas and 2D graphics drawing primitives. You will also need to process the low-level touch events, handle all pointing device events (e.g., trackball), handle all user feedback (e.g., flashing the menu choice when clicked), and so on.

You will also have to do this for everything else that you are trying to draw perpendicular to the screen orientation as well.

I am hoping you have a very large development team.

Isn't it possible to set the screenOrientation for each view?

No. Screen orientation is by the screen.

Whatever business problem you are trying to solve with mixed landscape-and-portrait, I suspect that you are trying to solve it the wrong way.

CommonsWare
Thanks for the comment. Why is it wrong? I'd like my application to be oriented according to the screen orientation, except for one view that I want to be always lanscape-oriented (some kind of visit card). When the device is in portrait mode, I still want the card to be landscape-oriented, but I want the menu to be portrait-oriented. Why is that so complicated to do that?
jul
@jul: "Why is that so complicated to do that?" -- because, strangely enough, most applications don't need to do that. You will be best served by allowing the activity to rotate as normal, and implement the "visit card" yourself by drawing it as a custom `View` using the `Canvas` and 2D drawing primitives.
CommonsWare