There are also four common density types: low (ldpi), medium (mdpi), high (hdpi), extra high (xhdpi)To declare different la S and images for different screens, you need to place these optional resources in different directories. This is similar to how to support multiple languages.
Considering the screen direction configuration in different screen sizes, many applications can achieve the best user experience by changing the layout in different directions.
Create different la sTo make your application have a good user experience on different screen sizes, you should create a unique XML layout file for each screen size you want to support. Each layout file should be stored in the appropriate resource directory with the directory name-
Suffix. For example, the name of a layout directory that stores large screens isres/layout-large/
.
Tip:The Android system automatically scales the layout to adapt to the screen correctly. Therefore, you do not need to worry about the actual size of the UI elements you have designed for different la S, note the layout structure that affects the user experience (for example, the layout of an important layout is relative to the layout size and position next to it ).
For example, this project includes a default layout directory and a layout directory for large screens:
MyProject/ res/ layout/ main.xml layout-large/ main.xml
The file names must be identical, but their content must be different to provide the best UI display for different screen sizes.
Simple reference layout in applications:
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main);}
The system adds the layout files in the appropriate layout directory based on the screen size of the device.