orientation - Android: Dynamically change location of Options Menu -


i have drawing activity creates custom 'canvas' view occupies entire screen, allowing user draw on it. have requirement lock activity portrait orientation, drawing app sketchpad replacement, , user have need rotate 'pad' draw without pad flipping around on them. of course means options menu locked orientation , depending on user, menu popping out of top, bottom or sides. i'd have options menu located @ bottom relative user... options considering , appreciate suggestions or info:

  1. allow orientation changes, menu moves needed, use sensormanager listen orientation, , manually rotate canvas view 'correct' orientation (portrait). ugly, there delay in rotation of canvas, , introduces potentially complex calculations, etc due x/y being swapped.
  2. restrict orientation changes, use sensormanager listen orientation, , manually rotate options menu bottom. no idea if possible.
  3. lock orientation, , create custom view intercepts menu button , displays 'fake' options menu need manage, etc. really don't want have replace built-in os functionality, nightmare maitain different versions of os in future, etc.

anyone have ideas on how handle this? i'd love if #2 possible, can't find related that.

thanks,

paul

edit:

have confirmed #2 not possible, guess options #1, #3, unless else has ideas?

my solution follows:

  • allow normal orientation changes in android manifest activity.
  • in custom 'canvas' view constructor, fire tracking field, mdisplay, gets display information via:

code:

mdisplay = ((windowmanager) mcontext.getsystemservice(context.window_service)).getdefaultdisplay(); 
  • in ondraw(), check see if display rotation other 0, , rotate canvas 0 rotation value:

code:

if (mdisplay.getrotation() > 0) {     canvas.save(canvas.has_alpha_layer_save_flag);     canvas.rotate(-mdisplay.getrotation(), px, py);     ...     stuff     ...     canvas.restore(); } 

not sure it's best solution, seems work.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -