开发者

Supporting multiple screen sizes with Android using ImageButtons

开发者 https://www.devze.com 2022-12-27 06:35 出处:网络
I\'ve read the Android documentation: http://developer.android.com/guide/practices/screens_support.html

I've read the Android documentation: http://developer.android.com/guide/practices/screens_support.html but still have some questions.

I'm trying to design a music application which basically has images of the instrument (ImageButton) that play a sound when clicked. However, I'm confused about how to have the ImageButtons scale to fit all the different screen sizes and how to position them.

  1. Which layout is best used for needing to position ImageButtons in specific locations on the screen? (i.e. cymbals on a drum set) FrameLayout, RelativeLayout?

  2. If I only really care about medium and large screens, do I need to create different resources (images) for both as well as a different XML layout to position them?

I'm trying to find the simplest way to do this without having to create a separate layout XML file for positioni开发者_高级运维ng/size and separate image resources for each screen.

Any guidance is greatly appreciated. Thanks!


Which layout is best used for needing to position ImageButtons in specific locations on the screen? (i.e. cymbals on a drum set) FrameLayout, RelativeLayout?

RelativeLayout. In the real world, cymbals are positioned relative to the drums.

If I only really care about medium and large screens, do I need to create different resources (images) for both as well as a different XML layout to position them?

In terms of the layout, you only need a different layout if the rules would differ. It is very possible that the positions of the cymbals relative to the drums would not change based on screen size.

In terms of the images, I would suspect you'll want separate versions for different screen densities, not for different screen sizes. That way, a cymbal will be (roughly) the same physical size (inches/millimeters), even though that takes more pixels on a high-density screen. If you use the same images for all densities, in some cases, the images may be too small to tap readily.

0

精彩评论

暂无评论...
验证码 换一张
取 消