Search code examples
androidandroid-studioscreenresolutionandroid-screen-support

Support différent screen résolutions, density


i have finished my application but now i see that the layout xml file is not compatible for all smartphone/tablets. So i did some search and i know that they're different folders for layout wml files and drawables, and the smartphone/tablets gonna pick in the good folders.

For exemple for layout xml files:

res/layout-small
res/layout
res/layout-large
res/layout-xlarge

That is the good way forthe layout xml files to support all résolutions ? But how to know which folders is for the 1440 X 2560 screen size ? And how to name the drawables folders ?


Solution

  • enter image description here
    -For layouts you can specify
    res/layout/my_layout.xml layout for normal screen size ("default")
    res/layout-small/my_layout.xml // layout for small screen size
    res/layout-large/my_layout.xml // layout for large screen size
    res/layout-xlarge/my_layout.xml // layout for extra large screen size
    res/layout-xlarge-land/my_layout.xml // layout for extra large in landscape orientation -- If you want to specify the screen basing on the dp you can spicify the name as

    res/drawable-mdpi/my_icon.png        // bitmap for medium density
    res/drawable-hdpi/my_icon.png        // bitmap for high density
    res/drawable-xhdpi/my_icon.png       // bitmap for extra high density
    

    -- If you want to specify basing on the smallest width you can specify as

    res/layout/main_activity.xml           # For handsets (smaller than 600dp available width)
    res/layout-sw600dp/main_activity.xml   # For 7” tablets (600dp wide and bigger)
    res/layout-sw720dp/main_activity.xml   # For 10” tablets (720dp wide and bigger)
    

    For more reference click here