Difference between dp, dip, sp, px

Screen density is the amount of pixels within an area (like inch) of the screen. Generally it is measured in dots-per-inch (dpi). Screen density is grouped as low, medium, high and extra high. Resolution is the total number of pixels in the screen.
dp: Density Independent Pixel, it varies based on screen density. In 160 dpi screen, 1 dp = 1 pixel. Except for font size, use dp always.
dip: dip == dp. In earlier Android versions dip was used and later changed to dp.
sp: Scale Independent Pixel, scaled based on user’s font size preference. Fonts should use sp.
Always use dp and sp only. sp for font sizes and dp for everything else.

Comments

Popular posts from this blog

@Overrride annotation introduced in Java1.5

Liskov Substitution Principle (LSP)

Marie Choco Lava