1. You need to add a child element below the elements in the Androidmanifest.xml file
Android:normalscreens= "true" android:anydensity= "true"
Android:smallscreens= "true" >
As the name implies, the above is a multi-resolution support for our screen (more accurately, the density of large, medium and small three). Android:anydensity= "true", this sentence is very important to the entire screen, the value is true, our application when installed on a different density of mobile phones, the program will load the resources in the HDPI,MDPI,LDPI folder separately.
Conversely, if the value is set to False, even if we have the same resource under the Hdpi,mdpi,ldpi folder, then the application will not automatically go to the appropriate folder to find resources, this is in high-density, and low-density mobile phones, such as a 240x320 pixel cell phone, If you set android:anydensity= "false", the Android system will convert 240x 320 (low density) to 320x480 (medium density), so the app will load the resources in the mdpi file on the small-density phone.
2. Careful people will find that since android2.0 started drawable files are replaced by three folders drawable-hdpi,drawable-mdpi,drawable-ldpi three folders, Some programmers in order to let the application load some images by default, they will deliberately go in the application after android2.0 to recreate the drawable folder, in fact, it is not necessary to do this, through the first paragraph of the analysis we learned that android:anydensity= " False, the application will convert the size density to medium density to load the resources in the MDPI. Here again, when android:anydensity= "false", the app will load the resources in the MDPI.
To summarize:
First: Android:anydensity= "true", the system will automatically find the corresponding folder according to the screen density
Second: android:anydensity= "false",
(1) If the drawable-hdpi,drawable-mdpi,drawable-ldpi three folders have different density of the same picture resource, then the system will load the resources in the Drawable_mdpi folder.
(2) If there is a high density image in the drawable-hpdi, the other two folders do not have the corresponding picture resources, then the system will load the resources in the drawable-hdpi.
(3) If there is a picture resource in the drawable-hdpi,drawable-mdpi, there is no corresponding picture resource in the drawable-ldpi, then the system will load the resources in the Drawable-mdpi folder.
3. Note the different representations of the various folders.
DRAWABLE-HDPI the picture is applied to the horizontal screen, also for the vertical screen
DRAWABLE-LAND-HDPI, when the screen is horizontal and high density, load the resources in this folder
DRAWABLE-PORT-HDPI, when the screen is vertical and high density, the resources in this folder are loaded
4. Sometimes it is necessary to dynamically set a value in the code, such as a map, the map's pin and the map's address cue box relative offsets are different on different densities of mobile phones. In this way, the screen density can be calculated by:
Displaymetrics metric = new Displaymetrics ();
Getwindowmanager (). Getdefaultdisplay (). Getmetrics (Metric);
int densitydpi =metric.densitydpi; Screen density dpi (120/160/240)
You can then set the cost for these densities separately in your code.
But this method is best not to use, the best way is in the XML file different density of the phone to set separately.
The offset of the map here can be set in the Dimens.xml file in the values-hpdi,values-mdpi,values-ldpi three folder
It is worth mentioning that:
40dp
-14dp
The negative number here is completely functional, and the system thinks it's a negative value.
5. Major mobile phone manufacturers have more or less changes to the Android operating system, of course, these changes will have some impact on our application
Like what:
(1) System source code in the Connection music service Aidl file package name: Com.android.music
(2) LG may modify the Aidl file in the package (for example, modified to Com.android.music.player), and modify the contents of the file (add a method, or reduce the number of methods, or modify the method name) then our app to be published on LG's mobile phone, then we have to change the The attached aidl file must be fully consistent with the LG manufacturer's modifications.
Android phone screen suitable recipe method