A book I've been reading recently is the authoritative guide to Android Application Development (fourth edition), which is highly recommended. The book describes some of the user interface design specifications, for beginners I think it is very necessary, here the code to everyone, hope for us all useful.
When we design our user interface, we always support specific device configurations by providing custom application resources and code, but it's important to note that we have to ensure that our designs have the flexibility to deal with all kinds of changes and make them simple rather than squeezing them too much. Here are some of my suggestions:
- Design normal-sized screens and medium-resolution apps. Over time, the device has a tendency toward greater size and greater resolution.
- Use fragment to keep your screen size separate from your app's activity class and provide a flexible workflow that uses Android support libraries authoring to provide updated support libraries for legacy platform versions.
- For the width and Height properties of view or layout, use Match_parent and wrap_content (that is, discard fill_parent) so that you can control the size of different screen sizes and direction changes. Instead of using a fixed pixel size.
- For dimensions, use flexible units, such as DP and SP, instead of using fixed units such as PX, MM, and in.
- Avoid setting and properties that are fixed with absolutelayout layouts and other pixels.
- Use flexible layout controls such as Relativelayout and LinearLayout, Tablayout, and framelayout to design the screen so that different screen sizes and resolutions in portrait and landscape mode are not all good to display. Try to organize your screen content using the "work with chunking" principle.
- Wrap the contents of the screen in an extensible container space, such as ScrollView and ListView. Normally we should scale or stretch the screen in one direction (vertical or horizontal) instead of both.
- Instead of providing exact positional values for screen elements, sizes, and dimensions, use relative positions, weights, and gravity directions. Spending time upfront to ensure correctness can save time in the future.
- Provide a graphic of reasonable high-quality applications and always maintain the original (larger) size to ensure that no version of the graphics can be used in the future for the unused resolution. There is always a tradeoff between graphics quality and file size. Find a suitable point to ensure that the graphics are scaled reasonably in different screen features without significant application or long time load display. Better, it is recommended to use the Nine-patch graphic, which allows the graphic to change size depending on the size of the display area
Hope that some of the above development norms can help everyone.
BOB
"The article comes from the authoritative guide for Android Application Development (fourth edition)" Some suggestions on how to design a compatible user interface (with deletions)