Photoshop pixels to Android dp -
i'm trying convert text dimension psd representation android dp format. on internet there resources explain dp, sp how convert them still don't understand do. need example case.
let's have psd 3 lines of text different dimensions:
18px font - ? dp 21px font - ? dp 28px font - ? dp
which dimensions choose handheld device if want maintain same apparent dimension? how make gui similar psd template?
taken this thread
- px 1 pixel.
- sp scale-independent pixels
- dip (dp) density-independent pixels.
use
- sp font sizes
- dp else
from android developer
+---------+-------------+---------------+-------------+--------------------+ | density | description | units per | density | same physical size | | | | physical inch | independent | on every screen | +---------+-------------+---------------+-------------+--------------------+ | px | pixels | varies | no | no | +---------+-------------+---------------+-------------+--------------------+ | in | inches | 1 | yes | yes | +---------+-------------+---------------+-------------+--------------------+ | mm | millimeters | 24.5 | yes | yes | +---------+-------------+---------------+-------------+--------------------+ | pt | points | 72 | yes | yes | +---------+-------------+---------------+-------------+--------------------+ | dp | density | ~ 160 | yes | no | | | independent | | | | | | pixels | | | | +---------+-------------+---------------+-------------+--------------------+ | sp | scale | ~ 160 | yes | no | | | independent | | | | | | pixels | | | | +---------+-------------+---------------+-------------+--------------------+
px pixels - corresponds actual pixels on screen.
in inches - based on physical size of screen. 1 inch = 2.54 centimeters
mm millimeters - based on physical size of screen.
pt points - 1/72 of inch based on physical size of screen.
dp density-independent pixels - abstract unit based on physical density of screen. these units relative 160 dpi screen, 1 dp 1 pixel on 160 dpi screen. ratio of dp-to-pixel change screen density, not in direct proportion. note: compiler accepts both "dip" , "dp", though "dp" more consistent "sp".
sp scale-independent pixels - dp unit, scaled user's font size preference. recommend use unit when specifying font sizes, adjusted both screen density , user's preference.
check out this thread aswell. (changing px dp programmatically)
Comments
Post a Comment