Differences between the DP and SP tags in android

Source: Internet
Author: User

Remember before the study of a teacher said we often use the size unit for DP and SP, and these two units what difference in today's study and I encountered. In the code described in the book, repeated occurrences are more dp,px. So, I would like to take advantage of this opportunity to figure out the dimensions involved so as to avoid wasting time on this issue later on.

Px:pixels, each pixel corresponds to a point on the screen and is generally used as the unit of focus when setting the resolution.

sp:scaled pixels, a proportional pixel, mainly handles the size of the font, and can be scaled according to the user's font size preference. Crucially, according to Google's recommendation, TextView's font size is best used for the SP font size. So here I'll remember that the unit must be using SP when tapping the character code.

DP: This is a very abstract description, called an abstract unit that describes the density of the screen.

Originally through the book here is not about the DP unit of a processing results, but through the degree Niang, only remember a word good, is to enable the user UI interface in the current and future mobile display type on the normal display, we recommend that you always use the SP as the text size of the Android system units, Use DP as the unit for other elements.

This is a rookie in the learning path of small problems, hope that the great god see the mistakes can help guide, first in advance thank you

Differences between the DP and SP tags in android

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.