Android Layout Unit Dip DP SP PX

Source: Internet
Author: User

Android layout commonly used units are dip, DP, SP, PX.

Dip/dp

Represents a density-independent pixel (density-independent pixel), which is an abstract unit based on the physical density of the screen. DP is relative to a 160dpi density screen, so the 160dpi density of the screen 1 DP represents a pixel. High screen density unit DP corresponds to high pixel value, low screen density unit DP corresponding pixel value is low. That is, different density of the screen, the unit DP corresponding pixel value is not the same. But remember a little bit, no matter what density, 1 DP on the screen always represents 1/160 inches, so that the different on-screen DP always represent the same size.

Usage scenario: Any scene except fonts

Sp

Represents a scale-independent pixel (scale-independent pixel), which is also a density-independent pixel, which is only affected by the font preference set by the user and follows the font size scaling.

Usage scenario: only in Font size

Px

Represents the pixel (pixel), the actual pixel of the screen.

Usage scenario: Try not to use it, but it can be used in scenes where exactly how many pixels are needed, such as: List Split line height


The following 2 pictures can help you better understand the above layout units





Android Layout Unit Dip DP SP PX

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.