Android adaptation (screen adaptation and international adaptation) and android adaptation
First, let's talk about Android screen adaptation:
About some basic concepts of Android screens, you can charge your own .. This section only describes how to use
1. When talking about Android screen adaptation, the first thing to do is image adaptation.
Image adaptation follows two principles: ① use a 9. path image as much as possible to automatically adapt to the screen ② use the least image resources as much as possible
Use the 9. path image in the first place: for example, topBar, bottom navigation, slide menu, and other buttons. Use the 9. path image whenever possible during background processing.
The second point is to use the least image resources: many people like to switch several sets of images to adapt to the screen, occupying the memory space, and the second is the United States...
First case: When images such as welcome pages and boot pages need to be filled with the entire screen, we need to make at least two sets of images to adapt to the screen (480*800, 720*1280) put in the corresponding folder
Case 2: directly cut the graph (480*800) and place it in the corresponding folder so that it can automatically adapt
Many people will question whether images will be pulled up or blurred. After my personal tests and feedback from several online projects, the above method can satisfy most mobile phones.
2. Layout adaptation
In the src directory to create a different resolution of the layout directory layout-1280x720 layout-800x480 in different layout directory to create a targeted layout file, the size inside the write dead do not matter...
3. dimens adaptationCreate a values directory with different resolutions under the src directory values-1280x720 values-800x480 create a dimens. xml file under a different values directory in this dimens file you can define its size for different resolutions
4. Weight adaptationUse weight to allocate screen usage (weight adaptation)
5. java code adaptationDynamically obtain the screen width and height, and then dynamically set the layout size.
Let's talk about the internationalization adaptation of Android:
1. Internationalization of strings:You only need to create the values folder of the corresponding language under the res folder, and then create strings under the corresponding values folder. xml: values-zh English environment: values-en American English environment: values-en-rUS Chinese environment: values-zh-cn
2. Internationalization of images:Under res, create the drawable folder in the corresponding language. In the English environment of drawable-en-ldpi drawable-en-hdpi drawable-en-mdpi, the Chinese environment is: drawable-zh-hdpi drawable-zh-ldpi drawable-zh-mdpi
Other brilliant articles
Android learning notes (38) create a skin import dialog box using ProgressDialog
Large-scale website architecture design-Solr
Android learning notes (39) Message tips use Toast tips to show tips
Android learning notes (32) grid view (GridView) and graphics switcher (ImageSwi...
Android learning notes (31) List component (ExpandableListView)