What is the best strategy to manage different scre

2020-03-30 01:53发布

问题:

As I know, not all WP7 have 480 x 800 pixels in resolution.

What is the best strategy to manage different screen resolutions in Windows Phone 7 ??

If I hardcode the width, height, margin, etc. in the xaml, will it be messed when the phone does not support 480x800 resolution ??

Let's share your thoughts.

Thanks.

回答1:

I have similar concerns around supporting smaller screens once they are available. When I asked Microsoft about it I got this response:

Minimize setting heights and widths directly. Use alignment, grids, stackpanel, etc. to layout the UI. As a test, you can create a desktop Silverlight version / mock of the project and test it in both resolutions.

When I asked Brandon Watson last week he told me not to worry about it as they were working on some clever ways to handle this.

I know with XNA that there is scaling support built in, so in theory that makes handling different screen sizes in XNA easier but still leaves the issue of touch target sizes and the ratio differences in the 2 screen sizes. - I don't find letterboxing to be a good look ;)

With Silverlight the problems are potentially more complex as the following needs to be accounted for:

  • Screen dimension ratio issues

  • Making large text smaller so it doesn't take up a disproportionate amount of screen space.

  • Not making smaller text smaller as it may become unreadable.

  • Ensuring that controls which support gestures are still large enough to recognise the gesture.

  • Ensuring that when neighbouring touchable controls are made smaller they still maintain sufficiently large touch targets that people can be confident about what they are touching.

  • Making large images smaller so they aren't larger than the available space.

  • Making sure that images aren't distorted when resized.

  • and many more...

All that said, we'll just have to wait and see what Microsoft come up with and then adjust our apps accordingly.



回答2:

Look at using StaticResource. These will change as the screen resolution and orientation change. See Petzold or this video.



回答3:

You could also take advantage of relative control sizing using grids.

See Grid section under

Object Positioning and Layout



回答4:

You DO NOT care about screen resolution in Silverlight and you DO NOT use with/height or position in layout.

First thing is you dont really know what is resolution of device, because you are doing everying in resolution-independent units.

General rule is, when doing layout, you do it in such way, that content is able to layout itself acording to space it has available. StackPanel and Grid are HUGE help in this case. If resolution changes, you dont really have to do anything (if your UI is done right).

Handling different resolutions in XNA is probably same as in desktop games. Again, there is not much to do other than setting correct transformation matricies.