1

I read info about "Supporting Multiple Screens" and other post here... but Im really confused about how can I develop my application that run on multipple devices. I was starting develop on a determinate screen (normal size layout), then I run my apk on a S4 galaxy so I see that every object of my apk was diferent size to my xperia to the S4. what I need to do to make my apk compatibility for all the devices? I read information that the only source to make that is:

  1. res/layout/my_layout.xml // layout for normal screen size ("default")
  2. res/layout-small/my_layout.xml // layout for small screen size
  3. res/layout-large/my_layout.xml // layout for large screen size
  4. res/layout-xlarge/my_layout.xml // layout for extra large screen size
  5. res/layout-xlarge-land/my_layout.xml // layout for extra large in landscape orientation

    For:

  6. res/drawable-mdpi/my_icon.png // bitmap for medium density

  7. res/drawable-hdpi/my_icon.png // bitmap for high density

  8. res/drawable-xhdpi/my_icon.png // bitmap for extra high density

is this true? so I need to make different layouts for different devices? guys please help me with this issue cz I relly dont understand how is the deal for multiple devices compatibility.

Alejandro Cabano
  • 145
  • 1
  • 4
  • 15

2 Answers2

1

For the layouts: You can most likely get away with one set of layouts for your application. By default, Android's gui system is done in such a way that you should be able to make good use of the screen of any device, for example use layout_weight and specify things in dp (density-independent pixels). By providing only one layout though, you're most likely going to have it optimized for phone or tablet sized screens. If you create it for phones, then tablets will probably have a lot of empty space, whereas creating another set of layouts would allow you to put extra info on the screen than the phone layouts could fit. It depends how willing you are to customize your app experience for each users device. To create multiple layout, it's recommended to use the Android 3.2 size qualifiers. For tablets, you could use res/layout-sw600dp. See here under "Using new size qualifiers".

For the drawables: You will most likely not want to have just one set of drawables. You can, and the Android system will scale all your drawables to maintain the same physical size on all screen sizes, but due to scaling, the images will not look very good. That's why you provide an image that will look good for each "category" of screen density, and the Android system will choose the one for that device's screen density, and any scaling it has to do will be minimal.

It is kind of confusing at first, but you most likely don't have to worry about the layouts specifiers just yet. I would make sure to read the supporting multiple screens article and writing your xml layouts such that they make use of the screen size in a relative way.

mpellegr
  • 3,072
  • 3
  • 22
  • 36
0

Have you read this page? Or this one?

You create resources with duplicate names located in folders that are qualified a certain way. At runtime, the system will choose the resources that best match the current configuration of the device. If you want your device to work on multiple screen sizes and multiple screen densities, you will need to create different resources (layouts, drawables, etc) and qualify them appropriately.

Karakuri
  • 38,365
  • 12
  • 84
  • 104