Android Course---phone size-related concepts + size units + about colors

Source: Internet
Author: User

Cell phone Size: The length of the screen diagonal, in inches (2.54cm)

The resolution of the phone: the number of pixels the screen can display, generally in the long direction of the number * wide direction of the number to express

Cell phone pixel density: pixels per inch, also known as PPI, that is, the number of pixels per inch screen can be displayed, the greater the pixel density, the more detail the display screen.

Calculation: pixel density ={1+√[(length of pixels-1) ^2+ (width pixels-1) ^2]}/screen size

The abbreviation for dpi:dots per inch (number of dots or lines to be printed) is used to indicate printer print resolution, but sometimes DPI is used to refer to PPI

Cell phone density: Density, 160ppi as the benchmark, that is, the pixel density is 160 Density 1

ldpi 120ppi 0.75

MDPI 160DPI 1.0

HDPI 240dpi 1.5

XHDPI 320DPI 2.0

Dimension units

Px:pixels (pixels)

The length of the 1px corresponds to the size of a pixel on the screen.

Dp/dip:device-independent pixels (device independent pixels)

1DP = (dpi/160) px

1DP = density px 160->1px 120->0.75 320->2px

1px = 1/density DP

sp:scaled pixels (retractable scaling pixel)

Similar to DP, but can be scaled based on the user's font size preference

Note: Android automatically converts the dimensions of dp/dip/sp to the values of pixel units at run time

Comparison of dimension units

What is the comparison between DP and PX?

The length in PX is bigger on the phone and smaller on the player.

The DP unit will not change

What is the comparison between DP and SP?

The user can set the size of the text in system settings

If the font size is used in SP, the setting is effective

If the font size is in DP, the setting has no effect

The width of the layout file view as far as possible with match_parent/wrap_content

If you must specify a specific value, use Dp/dip to make the unit

Text size using SP to do units

About Colors

Font color or background color in Android uses RGB to express

R:red Red

G:green Green

B:blue Blue

Each hue uses a 2-bit hexadecimal number to represent the color value preceded by a character: #

Example Red: #ff0000

Green: #00ff00

White: #ffffff

Black: #000000

What color can be used to check the color table.

Android Course---phone size-related concepts + size units + about colors

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.