Pergunta

I'm creating a drawing app for tablets and am interested in how to best handle the drawing canvas, relating to screen orientation changes. The drawing program tracks the user inputs and stores them as vectors, anchored by X,Y coordinates.

The issue relates to the different size of X,Y in portrait/landscape modes. If a user has a canvas that fills the screen (minus notification and title bars), and in portrait mode draws near the bottom of the canvas (say at point 140,460 on a 320x480 screen), when the screen gets flipped to landscape and recreated from the X,Y vectors that I've stored, the point at 140,460 is now out of the bounds of the screen (because the screen is now 480x320). Likewise, if they draw points in landscape near the right-hand edge of the screen and flip back to portrait, those points will be out of bounds.

I've looked around at solutions to this, and the obvious one seems to be to simply lock the screen down to a specific orientation. A number of the drawing apps I've downloaded from the Marketplace handle it this way.

As I'm designing this for a tablet, I'd like to give the user the flexibility to draw as they like, yet maintain some sanity when it comes to the screen bounds, etc.

Ideas I've had/tried include:

  • locking to a particular orientation - ok, but hate forcing user to a certain preference
  • locking to a particular orientation and hiding title and notification bars, so the user is simply presented a large blank canvas that they can use as they wish - but hate that the notification bar is hidden

I thought about the possibility of hiding the title bar, showing notification, allowing orientation change and then if the screen is rotated to landscape, rotating the canvas back to portrait, but when the navigation bar moves from what would have been the top in portrait to the right-hand side in landscape, I still get the same X,Y bounding issues, just to a much smaller degree (the width of the notification bar effectively).

Any thoughts on solutions for this?

Thanks.

Foi útil?

Solução

Implement scrolling/panning, and let the drawing surface be arbitrarily larger than the dimensions of the parent view. Then it doesn't matter if the device is in portrait or landscape. You'd just have a view acting as a window on a particular portion of the drawing surface.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top