Android adaption _ related concepts and applications

Source: Internet
Author: User

Android adaption _ related concepts and applications
There are several concepts and related formulas: 1. dp: device independent pixels (device independent pixels ), is the ratio of pixels to density dp = px/density 2, dpi (dot per inch points per inch) is equal to the ppi, is the ratio of the number of screens on the diagonal line and the size of the screen dpi = ppi = (√ (screenHeight ^ 2 + screenWidth ^ 2)/screen size (inch) 3. The density is the ratio of dpi to 160 density = dpi/160 4. The inch is the ratio of dpi or ppi, inch = px/dpi = px/ppi, you can only understand the following two cases (you can add different opinions). First, let's look at the first case (the screen width is the same, the resolution is different). 1. A mobile phone with a resolution of 480*800, width 480, height 800, height is generally affected by the virtual key, but the width is certain, with the width as the standard, therefore, generally distinguish by width 16 0 dpi the screen width is 3 inch, dp is 480dp 2, another resolution 720*1280 mobile phone width 720, height 1280 240 dpi screen width is 3 inch, dp is also 480dp so, the screen sizes of the two mobile phones are the same, but the resolution is different. Therefore, the dimens files with the same layout file are applicable to the two mobile phones, put drawable-mdpi and drawable-hdpi on the first mobile phone. The displayed result is normal but small on the second mobile phone. Therefore, the high-density images should be larger (note: if there is only one set of images, such as in drawable-mdpi, the image size is the same.) The second case (the resolution is the same and the screen width is different) 1. A mobile phone with a resolution of 720*1280 is 720 wide, the screen width of 1280160 dpi is 4.5 inch, the dp is 720 dp 2, and a mobile phone with a resolution of 1280*720 is wide, high 1280240 dpi screen width: 3 inch, Dp is dp. Based on the results of the previous scenario, the image will be of different sizes. The layout and size may be different now. Therefore, the layout and size must be adapted, if different screen sizes require different la s. For example, the first phone, may be the size of the tablet, layout and mobile phone different, layout can not be applied to the tablet, therefore, you need to re-create a folder re-layout such as the layout-sw720dp second phone, layout is also different, the size of the view may be different for different screen sizes that need to be built with dimen in values. the following directory values-sw720dp, values-sw480dp sw720dp, sw480dp formats may be created for the xml file, so the size also needs to be adapted: sw <N> dp (smallestWidth) screen landscape switching, the minimum screen width is not changed. w <N> dp: the screen width is changed based on the screen width. N indicates the screen width, in the unit of dp and PX, the width is different, so there will be different directories in this way is 3.2 to start to use, before using small, normal, large, xlarge directory name example: layout-sw720dp, l Ayout-sw480dp, layout-sw320dp, layout-large, values-sw480dp and so on, now I understand the adaptation of these two situations 1, the screen width is the same, different Resolutions (applicable to different density pictures, different density styles, themes, etc.) 2. The resolution is the same, and the screen width is different (applicable to different la S and different sizes, from the android generated directory structure, there should be a third, adapt to different versions such as values directory will have values-v11, values-v14, There is only style inside. xml is a different topic. It may be android of different versions. The topic is newly added. If you want to use the new ui in the new version, the adaptation is unconfirmed. It is just speculation.

Related Article

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.