Android interface development

Source: Internet
Author: User

Why use dp/dip? What is the appropriate dp value for the width/height of the navigation bar? In general, how many heights should each control display? This article aims to solve these problems. 1. During Android development, we cannot ignore the issue of device adaptation. When we first started learning android, we were tired of saying, "android fragmentation is serious, adaptation is troublesome" and "the length of the control is measured in dip, word body with sp "and so on. It is necessary for us to have a detailed understanding of these things so that they can be easily used in the development process. The following are common units in android: px (pixel) can be understood as a small color block, which is the unit of display on the device; dip is an independent pixel on the device, and different devices have different display effects, note: dip = dpdpi indicates the screen pixel density, the number of pixels per inch, and sp indicates the pixel scaling. Google recommends font display. Dpi equals the number of pixels in the diagonal line (=) in addition to the number of inches. For example, the resolution is 480x800, and the screen size is 4.3 inch DPI. for convenience, google divides dpi into multiple modes: LDPI, MDPI, HDPI, XHDPI, XXHDPI, and XXXHDPI. The four common examples are corresponding to the four Suffixes in the resource file: that is, 216 is divided into hdpi. Here is a benchmark: 160. Because the first Android device (htc t-Mobile G1) belongs to (approximately equal to) 160 dpi, with 160 as the benchmark, multiply by 0.5, 1, and 2 can better correspond to a dpi mode. Therefore, the formula for converting dip to px is as follows: px = dp * (dpi/160). In short, the Unit dp is similar to px in performance, but its length is not fixed, changes based on the current hardware parameters. The wider the value, the longer each dp (relative to a fixed px). The narrower the value, the shorter each dp. Therefore, in order to have a better display effect, according to google's recommendation, the font should use sp as the Unit, and other elements should use dp as the unit. 9 for the image to be scaled. 2. The Android system is already full of flowers, and mobile phones, TVs, tablets, watches, and so on can be flushed into the Android system. Its open-source nature makes it far greater than the market share of other systems. For mobile phones and tablets, google officially uses handset for phones below 600dp and tablet for tablets above 600dp ).

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.