Dynamic loading layout skills

Why can

Dynamic loading layout can program according to the resolution or screen size of the device at runtime to determine which layout is loaded.

Qualifier

Screen features Qualifier description
size small Provide resources to small-screen devices
nomal Resources available to the middle of the screen device
large Provide resources for large-screen device
xlarge Resources available to large screen devices
Resolution ldpi Resources available to low-resolution devices (120dpi or less)
mdpi Resources available to the moderate resolution device (120 ~ 160dpi)
hdpi High resolution resources available to the device (160 ~ 240dpi)
xhdpi Ultra-high resolution to the resource providing device (240 ~ 320dpi)
xxhdpi Ultra high resolution resources available to the device (320 ~ 480dpi)
direction land Resources available to the horizontal screen devices
port Resources available to the vertical screen device

Minimum width qualifier

Sometimes we want to add more flexibility in layouts for different devices, then you can use the minimum width qualifier. Qualifier allows us to specify the minimum width of a minimum value (in units of dp) of the width of the screen, then the minimum value of the critical point, the screen width is greater than the value of the device to load a layout, it is smaller than this width loading another layout .

How to use

  • It is a direct qualifier New layout-large file, in this file New activity_main, xml layout.
  • Qualifier is the minimum width of the new layout-sw600dp file, a new file in this activity_main, xml layout can.
Published 25 original articles · won praise 18 · views 2123

Guess you like

Origin blog.csdn.net/weixin_43568110/article/details/95195424