To adapt to different screens, the first thing you need is to be able to distinguish different screens, andAndroid offers several different dimensions to qualify (qualifier, some translated as qualifiers)
As shown in some of the commonly used dimensions, but not all, all dimensions can be found in the official list.
From left to right, the arrows indicate the priority of the direction in descending order (priority is used to find the matching resource), and must be named when the res subdirectory is named with a qualifier, for example Res-sw600dp-port is right and RES-PORT-SW600DP a compile error. Some dimensions can have many different specific parameters, such as smallestwidth, some can only have fixed some options, such as language, screen orientation Port/land this.
Each dimension is described below:
1, language (zh-rcn), the main can be used in the ISO 639-1 Standard definition of the two-letter language code
2,smallestwidth the shortest available width (sw-<n>dp), this is from android3.2 start adding, indicating the shortest width available for the device, regardless of the screen orientation. However, when used, this parameter involves some components on the screen, and if there is navigation bar on the screen , the shortest available width may not be the number of the shortest edge of the screen, because this parameter refers to our UI the available intervals.
Adaptation process: When multiple catalogs use the qualifier, the matching principle is not greater than the maximum available width. That is, if the shortest edge of the screen is 1536, the screen density is xhdpi(i.e. 320dpi),1536/2 = 768 , then in all the SW-<N>DP select less than or equal in 768 the maximum value, which is the search for a match down.
3.Available width (w-<n>dp) is similar to Smallestwidth, But in relation to the screen orientation, match down
4,screensize screen size , according to the screen diagonal size to define (units inch- inches), can be divided into small/normal/large/xlarge . The adaptation order is from high to low, crash if there is only one definition in the catalog that exceeds the current actual size . This dimension has not been recommended since android3.2, and it is recommended to use shortestwidth.
5, the screen direction , this is the simplest, horizontal portrait
6,screen density density (dots per inch),ldpi/mdpi/hdpi/xhdpi/xxhdpi The corresponding screen density is 120/160/240/320/480/640dpi, the resource size should be proportional when the resource is placed. (Decide How many pixelthe 1DP represents).
Adaptation process: Priority from the current screen density matching directory lookup, if not constantly looking to the upper layer (tend to reduce the size of the large picture, rather than small image amplification), if the upper layer is not to look down to the lower level, if not, to take the default directory, to navigate to a specific directory, Is scaled based on the proportion of the directory that is anchored to the current screen density.
7, resolution (800*480), no official documents, but still available, priority is between nav and platform , the adaptation sequence is from high to low
8.Platform version: see Api levels. The adaptation sequence is also high to low
Android Resource matching process :
Best Practice:
1, for different screen size and direction to provide different layout,dimen
2. provide different drawable for different screen density dpi
3. Provide default resources to prevent crash
4, modify the value of a directory, confirm whether the upper layer has configured the parameter value, if there is, you can directly modify, if not, you want to copy the value of this layer to the upper layer before you modify the value of this level
Android Official :
Https://developer.android.com/guide/topics/resources/providing-resources.html
Https://developer.android.com/guide/practices/screens_support.html
Android screen adaptation rules