Android DPI computing

Source: Internet
Author: User

How to calculate the screen DPI?

As long as we know the screen resolution and size (diagonal line length), we can calculate the corresponding screen density, and then obtain the screen density according to its range.

Dpi can be calculated based on the length or width. The formula is as follows:

DPI = width/(size 2 x Width 2)/(width 2 + height 2) 1/2 = length/(size 2 x height 2) /(2 + 2 in width) 1/2

 

The approximate calculation method is as follows:

1. For example, if the resolution is 320 × 480, the aspect ratio is. 5.

2. For example, if the screen size is 3.6, the following elements are obtained based on the theorem:

Height 2 + width 2 = 3.62,

Also, because the height = 1.5 x width is substituted into the upper formula, there are:

Width 2 + 2.25 x Width 2 = 12.96,

It is concluded that the width is (12.96/3.25) 1/2 = 1.9969

3. The width is 320px and is distributed on 1.9969 ", so the density is 320/1 .9969 = 160.2467.

4. Therefore, this density is about the mdpi density.

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.