Android Basics (Device display density/image adaptive

Source: Internet
Author: User

1. The display density of the device is determined by two factors: the size of the device and the resolution of the device. The larger the size of the same resolution device, the smaller the display density, the higher the resolution of the device with the same size, the greater the display density.

2. Display density rating: 160/240/320/...

3. At different display densities, the conversion ratio of DP to PX is not the same:

When the density is 160, 1DP = 1px; When the density is 240, 1DP = 1.5px; Density is 1DP = 2DP;

4. In Android, the general width is high with DP,

5.-?? in different drawable DPI folder (such as drawable-hdpi), the same name, the same meaning of the picture, when the final app runs on different display density devices, will be limited to use the corresponding drawable folder picture.

6. The new version of ADT recommends replacing the Drawable folder with the Mipmap folder (because some density levels are not 160/240/320/... But the mipmap between them will be better dealt with.

7. Graphical resources should be stored in the Drawable folder, or in the drawable-nodpi folder.

8. Make the Fillet button:

1) Create an. xml file (file name does not need to add. xml) such as: Button_shape, choose Resource Type:shape,

2) <corners

android:radius= "10DP"//radius of the Circle

/>//Fillet

3) <gradient

Android:startcolor: "#ff00ff"

Android:centercolor: "#00ffff"

Android:endcolor: "#ffff00"

/>//Gradient color, (if you want to use a color, you can set the StartColor and EndColor to the same color can be achieved)

4) Android:[email the button Protected]/button_shape

9. Android is not recommended to write a string in the program, it is recommended to write in @string

10. Language International and Adaptive: device switching in different locales, the text on the app also switches automatically. You do this by creating a folder under Res that values-a language name (such as Chinese: values-zh), and then using an XML file under the file to store the text resource (string resource). Add: Folder full name (values-language name-R region name, such as: VALUES-ZH-RHK), language name all lowercase, region name all uppercase.

Android Basics (Device display density/image adaptive

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.