Multiple screen support do we need different layouts for each screen

前端 未结 4 1211
温柔的废话
温柔的废话 2020-12-10 23:42

For Multiple screen support do we need different layouts for each screen which goes in hdpi, ldpi and mdpi folders, I read this on android site, but not sure how to implemen

4条回答
  •  庸人自扰
    2020-12-10 23:52

    Let's assume that you have a default, good-looking layout in the layout folder. In most cases, Android will be able to adjust it properly. In my practice, only large screens require a new layout parameters.

    To avoid layout duplication, we use the following layout structure:

    res/layout/foo.xml                      -- layout file
    res/values/foo_styles_default.xml       -- default styles (component sizes, margins, etc.)
    res/values-large/foo_styles_large.xml   -- styles for large screen
    res/values-xlarge/foo_styles_xlarge.xml -- styles for very large screen
    

    Screen-size-dependent parameters in the 'foo.xml' layout are set via the 'style' attribute, thus allowing us to avoid creating multiple layout files.

提交回复
热议问题