最終更新:2018-03-12 (月) 16:40:20 (2237d)  

Android/dp
Top / Android / dp

dip: density-independent pixel

計算

  • DPI=160のときにdp=px
  • DPI=320だとdp=px/2

density

  • (dpi / 160)
    名称DPIdensity
    xhdpi?~320dpi2.0
    hdpi?~240dpi1.5
    mdpi~160dpi1.0
    ldpi?~120dpi0.75

ro.sf.lcd_density

Android/設定修飾子

基準

  • The generalized sizes and densities are arranged around a baseline configuration that is a normal size and mdpi (medium) density.
  • This baseline is based upon the screen configuration for the first Android-powered device, the T-Mobile G1 (ADP1), which has an HVGA screen (until Android 1.6, this was the only screen configuration that Android supported).

優先順位

  • xxx-h<N>dp > xxx-sw<N>dp > xxx-w<N>dp > xxx(デフォルト)

dpの例

  • 320dp?: a typical phone screen (240x320 ldpi?, 320x480 mdpi, 480x800 hdpi?, etc).
  • 480dp?: a tweener tablet like the Streak (480x800 mdpi).
  • 600dp: a 7" tablet (600x1024 mdpi).
  • 720dp?: a 10" tablet (720x1280 mdpi, 800x1280 mdpi, etc).
    res/layout/main_activity.xml           # For handsets (smaller than 600dp available width)
    res/layout-sw600dp/main_activity.xml   # For 7” tablets (600dp wide and bigger)
    res/layout-sw720dp/main_activity.xml   # For 10” tablets (720dp wide and bigger)

関連

参考