Friday 12 April 2013

Mengenal ukuran di android pixels, density, dpi, dip, dp, dps, sp, sip

ok mari kita mengenal jauh lebih dekat dengan ukuran android

tipe ukuran yang biasa kita pakai pada android

dp atau dip
Density-independent Pixels - An abstract unit that is based on the physical density of the screen. These units are relative to a 160 dpi (dots per inch) screen, on which 1dp is roughly equal to 1px. When running on a higher density screen, the number of pixels used to draw 1dp is scaled up by a factor appropriate for the screen's dpi. Likewise, when on a lower density screen, the number of pixels used for 1dp is scaled down. The ratio of dp-to-pixel will change with the screen density, but not necessarily in direct proportion. Using dp units (instead of px units) is a simple solution to making the view dimensions in your layout resize properly for different screen densities. In other words, it provides consistency for the real-world sizes of your UI elements across different devices.
sp
Scale-independent Pixels - This is like the dp unit, but it is also scaled by the user's font size preference. It is recommend you use this unit when specifying font sizes, so they will be adjusted for both the screen density and the user's preference.
pt
Points - 1/72 of an inch based on the physical size of the screen.
px
Sesuai dengan piksel yang sebenarnya pada layar. Ini satuan ukuran tidak dianjurkan karena hasilnya dapat bervariasi di seluruh perangkat, setiap perangkat  memiliki pixel layar yang berbeda
mm
Millimeters - ukuran dalam milimeter (10 mm = 1cm)
in
Inches - ukuran dalam inchi (1 inchi = 2.54 cm)
perbedaan pada  ukururan layar sama resolusi beda menghasilkan  (http://blog.edwinevans.me/?p=131)






































Lower resolution screenHigher resolution, same size
Physical Width1.5 inches1.5 inches
Dots Per Inch (“dpi”)160240
Pixels (=width*dpi)240360
Density (factor of baseline 160)1.01.5
Density-independent Pixels (“dip” or “dp” or “dps”)240240
Scale-independent pixels (“sip” or “sp”)Depends on user font size settingssame

TIPS memakai sp/dp  akan membuat aplikasi android anda kompatibel dengan beberapa resolusi, kepadatan ,ukuran layar  yang berbeda

referensi:
http://developer.android.com/guide/topics/resources/more-resources.html#Dimension

semoga berguna

No comments:

blog ini ditujukan pada smua orang yang mempunyai penghargaan tertinggi terhadap sesuatu yang mereka cinta dan sayangi