Concepts of PX and dip in Android UI development

Source: Internet
Author: User
 dip is not the pixel density, and the pixel density is DPI. Quote: dip: Device Independent pixels (device independent pixel ). different devices have different display effects, which are related to the hardware of the device. We recommend that you use this function to support WVGA, hvga, and qvga without pixels. Well, let's get to the point. Let's talk about PX first. PX is a pixel. If PX is used, it will be drawn using the actual pixel. For example, draw a horizontal line with a length of PX, in a 480-width simulator, the screen width is half the screen width, and in a 320-width simulator, the screen width is 2/3. DIP is to divide the screen's high score into 480 points and the width into 320 points. For example, if you build a 320 dip horizontal line, whether you are on a 480 or simulator, it is half the screen length. So your problem is solved: Question 1: Why is the code in  Code , the Unit PX and dip I wrote are the same in the same simulator? It's not about dip! = Px? A: If the width of your simulator is 320 pixels, 100dip is the same as 100px. Question 2: Why is the running result length of simulator 1 different from that of simulator 2? It seems that the length of simulator 1 is a little longer (because simulator 1 shows 512 in full) A: You may have two simulators with different width and height, so the dip display is different. 
Http://blog.sina.com.cn/s/blog_9d708b4f01015lz8.html

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.