4

In Android is it ok do set the width of a linear layout to 320dp? Can it be to big for some small screens?

On the internet people say that 320dp is the smallest android screen, but I just want to ask if someone tested this. Thanks

This question is related to android dp size for LinearLayout but nobody answered the question so I wanted to try to ask the question in a different way

Community
  • 1
  • 1
Andrei Ciuca
  • 165
  • 1
  • 3
  • 17
  • 1
    Yeah, it must be so. But it has Chinese devices with not standart screens. So, I recomend u to not set more that 240 dp size. – Denis Sologub Oct 28 '16 at 11:17
  • Ask yourself if you really need setting width of layout to fixed number. How about match_parent, wrap_content, or using percentages? You can of course use different dimens.xml for different screens, but usually you can prevent that. – poss Oct 28 '16 at 11:25
  • https://material.io/devices/ for the standard devices I see that only watches have a smaller dp – Andrei Ciuca Oct 28 '16 at 13:07

2 Answers2

0

You can use multi layout files as docs for small and large screens. We have 2 positions (landscape and portrait) and 2 sizes (normal and large) of screen. So, there are 4 types of layout.

res/
    layout/              # default (portrait)
        main.xml
    layout-land/         # landscape
        main.xml
    layout-large/        # large (portrait)
        main.xml
    layout-large-land/   # large landscape
        main.xml

You have to create layout file with same name in them.

Akbar
  • 430
  • 4
  • 18
0

Instead of using fixed size you should try match_parent vs wrap_content.

On the internet people say that 320dp is the smallest android screen

Smallest device that I know is 240dp x 320dp which means 240dp is the smallest device size.

See following links for clarity

What is the difference between match_parent and fill_parent?

Supporting Different Screen Sizes

http://www.randomlytyping.com/blog/2014/2/9/matchparent-vs-fillparent

ViewGroup.LayoutParams

Update

Smallest device can have resolution of 180px x 240px = 240dp x 320dp

enter image description here

Community
  • 1
  • 1
  • 1
    `240px != 240dp`. As rule, 240x320 px devices use ldpi so `320dp * 0,75 = 240px` – Denis Sologub Oct 28 '16 at 11:41
  • yeah, i see, and? – Denis Sologub Oct 28 '16 at 12:10
  • Thanks for the answer but I think that 240x320 is not in dp. It is important how you measure that value. 2560x1600 is for sure not dp – Andrei Ciuca Oct 28 '16 at 12:13
  • https://developer.android.com/guide/practices/screens_support.html Configuration examples To help you target some of your designs for different types of devices, here are some numbers for typical screen widths: 320dp: a typical phone screen (240x320 ldpi, 320x480 mdpi, 480x800 hdpi, etc). 480dp: a tweener tablet like the Streak (480x800 mdpi). 600dp: a 7” tablet (600x1024 mdpi). 720dp: a 10” tablet (720x1280 mdpi, 800x1280 mdpi, etc). this is what they say – Andrei Ciuca Oct 28 '16 at 12:13
  • it says that devices that has this resolution (in pixels), as rule, have XXX pixels per inch (or dots per inch). I.e. 240x320 pixels has 120 dpi. – Denis Sologub Oct 28 '16 at 12:15