0

wide range of products with Android OS. we have from 240x320 px to 640x480 px... Any suggestion to keep design in layout? What should i do? Could we work with percentual values?

shyam
  • 1,276
  • 4
  • 25
  • 51

3 Answers3

2

Yes you can work with percentual values using the layout_weight attribute. See this post for more explanations : What is android:layout_weight attribute?

What you should also consider is adding resources for different screen resolutions and densities. You should read this guide : Supporting Multiple Screens.

Good luck.

Community
  • 1
  • 1
Ovidiu Latcu
  • 71,607
  • 15
  • 76
  • 84
  • 1
    To add to the above... the layout_weight attribute works only in certain situations. The second link is your best guide to supporting multiple screen sizes densities and form factors. – Archit Oct 05 '11 at 12:10
  • @Archit and Ovidiu thanks for useful answering...means we have to make 3 layout for different-2 screen density and resolution and also save image in draw able folder for ldpi,hdpi and mdpi ,means same images would be reside in all 3 folder and layout automatically select for corresponding dencity screen?am i right? – shyam Oct 05 '11 at 12:21
  • 1
    no you don't have to make diffrent layouts. just use `dp` when you define your fixed dimensions and provide resources for ldpi,mdpi,hdpi – Ovidiu Latcu Oct 05 '11 at 12:27
  • but now we have to save same image in all these 3 folder? – shyam Oct 05 '11 at 12:34
  • Like @OvidiuLatcu says, you don't *have* to. Do you believe that a larger screen would benefit from a different layout? Then you could specify different layouts optimized for different screen sizes. For the images bit, I'll add an answer below, so that I can format it better. – Archit Oct 05 '11 at 12:35
1

Using sp (Scale-independent Pixels) or dp (Density-independent Pixels) while coding is one way for automatic handling of scaling.

I think you should stick to android's hdpi, mdpi and ldpi conventions.

Reno
  • 33,594
  • 11
  • 89
  • 102
0

As far as images go. Use this as a rule of thumb.
For each layout, determine the images that are appropriate for an mdpi screen. Then use the conversions below as a guideline for supplying images for the other screen densities.

For ldpi: 1dip = 0.75px
For mdpi: 1dip = 1px
For hdpi: 1dip = 1.5px
For xhdpi: 1dip = 2px

Note that this is a rough guide to help you determine how to scale your images for different screen densities. You may want to vary them depending on how it looks on the screen.

To try out different screen densities, set the abstracted LCD density in your emulator's settings in the following manner:

ldpi 120
mdpi 160
hdpi 240
xhdpi 320

Hope this helps!

Archit
  • 887
  • 2
  • 10
  • 19