Android Talk about design and screen adaptation

Source: Internet
Author: User

Extends:http://www.ui.cn/detail/45435.html

Http://www.2cto.com/kf/201501/372699.html

Http://www.cnblogs.com/bluestorm/p/3640786.html

http://www.shejidaren.com/android%E7%B3%BB%E7%BB%9F%E5%AD%97%E4%BD%93%E8%A7%84%E8%8C%83%E4%B8%8E%E5%BA%94%E7% 94%a8%e6%8e%a2%e7%b4%a2.html

Recently changed a new project to do, but the design to the size of iOS (1366*640), so the amount of the result is iOS, and not for Android, so in-depth study of how to convert.

The first thing to know

Android Common units:

1. Screen size in (inch): refers to the actual physical size, for screen diagonal measurement. Generally speaking the size of units are in inches, such as iphone5s screen size is 4 inches.

2. Pixels (pixel): The basic coding of the dots on the screen, the basic original pigments and their grayscale.

3. Resolution (Resolution): Refers to the number of pixels in the vertical and horizontal directions on the screen. (e.g. iphone5s resolution is 1136*640)

4.dpi:dotper inch, is the number of pixels, also known as screen density. The larger the value, the clearer the screen will be.

5. Dp=dip:device independent pixels (device independent pixel): An abstract unit based on screen density. 1DP = 1px on a monitor 160 dots per inch.


6. Sp:scale-independent pixels, it is the font unit of Android, the 160PPI screen as standard, when the font size is 100%, 1sp=1px.

Understanding of the PPI:

Ppi= Pixels per inch, the number of pixel pixels on the

Screen size in (inches): refers to the actual physical size, which is measured on the diagonal of the screen.

And the PPI is calculated as:

PPI =√ (length pixels ²+ width pixels ²)/Screen diagonal inches

For a simple example, what is the PPI of iphone5? Ppi=√ (1136px²+ 640px²)/4 In=326ppi (Retinal retina screen)

To solve the fragmentation of Android devices, introduce a concept DP, an abstract unit based on screen density.

Android divides the screen density into four generalized sizes:

Low (120ppi), Medium (160ppi), High (240ppi), and ultra-high (320ppi)

DP is (device independent pixels) different devices have different display effects, this and device hardware is virtual pixels, on different pixel density devices will be automatically adapted.

On a 160ppi per inch display, 1dp= 1px.

About DP and PX Unit conversions:

the PPI is calculated as:

PPI =√ (length pixels ²+ width pixels ²)/Screen diagonal inches

Dp:density-independent pixels, with 160PPI screen as standard, then 1dp=1px,

Sp:scale-independent pixels, which is the font unit for Android, is the standard 160PPI screen, when the font size is 100%, 1sp=1px.
Dp=dip:device independent pixels (device independent pixels) different devices have different display effects, this is related to the device hardware, generally we support WVGA, HVGA and QVGA recommend this, do not rely on pixels.

PX = dp*ppi/160
dp = px/(ppi/160)

PX = sp*ppi/160
sp = px/(ppi/160)

DP is a density-independent unit of pixels, on a screen of 160 dots per inch, 1dp=1px

Conversion formula for DP and PX: dp*ppi/160 =px

For example, in a 240ppi screen, such as 1DP x 240/160 = 2px. namely 1dp=1.5px,

MDPI (160ppi) 1DP = 1px; HDPI (240ppi) 1dp=1.5px;

XHDPI (320ppi) 1dp=2px; XXHDPI (480ppi) 1dp=3px;

For designers, we need to convert the DP to PX, just using the formula:

px=dp*ppi/160

Finally, put a few pictures to help understand:

Then get:


In general, DP,
Font size with SP,
Draw the line with PX.
When you use the iOS design to develop Android, I use the Android size is 1920*1080, DPI 480 will take the measured PX value divided by 1.  77777777777 is to write in the XML layout of the DP value, the amount of PX value divided by (iOS dpi-326/160), that is, the PX divided by 2.037308273 to get the size of the font

My dimen.xml is attached below.

<Resources>    <!--IOS Text -    <dimenname= "Ios_text_scale">2.037308273dp</dimen>    <!--Navigation title -    <dimenname= "text_navi_title_36">18sp</dimen>    <!--Positive text title -    <dimenname= "Text_content_30">15sp</dimen>    <!--Small characters -    <dimenname= "Text_content_small_28">14sp</dimen>    <!--Label Word -    <dimenname= "Text_label_24">12sp</dimen>    <!-- Line -    <dimenname= "Line_size_1">1px</dimen>    <!--IOS -    <dimenname= "Ios_scale">1.777777dp</dimen>    <dimenname= "Ios_2">1dp</dimen>    <dimenname= "Ios_3">2dp</dimen>    <dimenname= "Ios_5">3dp</dimen>    <dimenname= "Ios_8">5dp</dimen>    <dimenname= "Ios_10">6dp</dimen>    <dimenname= "Ios_15">8dp</dimen>    <dimenname= "Ios_20">11dp</dimen>    <dimenname= "Ios_25">14dp</dimen>    <dimenname= "Ios_30">17dp</dimen>    <dimenname= "Ios_35">20dp</dimen>    <dimenname= "Ios_40">23dp</dimen>    <dimenname= "Ios_45">25dp</dimen>    <dimenname= "Ios_50">28dp</dimen>    <dimenname= "ios_100">56dp</dimen>    <dimenname= "ios_150">84dp</dimen>    <dimenname= "ios_200">113dp</dimen>    <dimenname= "ios_250">141dp</dimen>    <dimenname= "ios_300">169dp</dimen>    <dimenname= "Iv_show_height">186dp</dimen></Resources>

Finally, we recommend a measurement label software: Mark man mark Eel, very useful.

Http://www.getmarkman.com/#/download-modal need to download adobe Air

Android Talk about design and screen adaptation

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.