Skip to content

Instantly share code, notes, and snippets.

@patrickhammond
Last active April 30, 2018 21:26
Show Gist options
  • Save patrickhammond/7b9ced016c4471312402 to your computer and use it in GitHub Desktop.
Save patrickhammond/7b9ced016c4471312402 to your computer and use it in GitHub Desktop.
Android highlights, hints, helpers, etc.

Platform versions

  • 1.5 (3 - Cupcake)
  • 1.6 (4 - Donut)
  • 2.0 through 2.1 (5, 6, 7 - Eclair)
  • 2.2 (8 - Froyo)
  • 2.3.1 through 2.3.3 (9, 10 - Gingerbread)
  • 3.0 through 3.2 (11 - Honeycomb)
  • 4.0.0 (14 - Ice Cream Sandwich)
  • 4.0.3 (15 - Ice Cream Sandwich - MR1)
  • 4.1.2 (16 - Jelly Bean)
  • 4.2.2 (17 - Jelly Bean - MR1)
  • 4.3 (18 - Jelly Bean - MR2)
  • 4.4.2 (19 - Kit Kat)

Density multipliers

  • LDPI - 0.75x (1px = .75dp)
  • MDPI - 1.0x (baseline; 1px = 1dp)
  • HDPI - 1.5x (1dp = 1.5px)
  • XHDPI - 2x (1dp = 2px)
  • XXHDPI - 3x (1dp = 3px)
  • XXXHDPI - 4x (currently only used for launcher icons on xxhdpi+ Kit Kat devices - https://plus.google.com/+RomanNurik/posts/EURexV9yF32)

Standard font sizes

  • TextAppearance.Large - 22sp
  • TextAppearance.Medium - 18sp
  • TextAppearance - 16sp
  • TextAppearance.Small - 14sp
  • TextAppearance.Micro - 12sp

Useful style references

  • android:TextAppearance([Small|Medium|Large])
  • ?android:textAppearance([Small|Medium|Large])

Font scaling

1sp = 1dp (Normal scaling) Font sizes are user adjustable (either for preference or accessibility need)

  • System Settings -> Display -> Font size -> (Small, Normal, Large, Huge) (0.75x, 1.0x, 1.25x, 1.5x, respectively)
  • System Settings -> Accessibility -> Large Text

http://mobile.tutsplus.com/tutorials/android/android-user-interface-design-basic-font-sizes/

Device profiles

  • Nexus 5 - 1920x1080px / 640x360dp (~1.78 w/h ratio) / XXHDPI
  • Nexus 7 (2nd gen) - 1920x1200px / 960x600dp / (~1.6 w/h ratio) / XHDPI
  • Nexus 10 - 2560x1600px / 1280x800dp / (~1.6 w/h ratio) / XHDPI
  • Moto X - 1280x720px / 640px360dp (~1.78 w/h ratio) / XHDPI
  • Galaxy S II 800x480px / 533x320dp (~1.67 w/h ratio) / HDPI

Tablet optimization

http://developer.android.com/distribute/essentials/quality/tablets.html

  • res/drawable-xhdpi (less than ~7" tablet (phones), portrait)
  • res/drawable-land-xhdpi (less than ~7" tablet (phones), landscape)
  • res/drawable-sw600dp-xhdpi (~7"+ tablet portrait)
  • res/drawable-sw600dp-land-xhdpi (~7"+ tablet, landscape)
  • res/drawable-sw720dp-xhdpi (~10"+ tablet, portrait)
  • res/drawable-sw720dp-land-xhdpi (~10"+ tablet, landscape)

Decent starting points for tablet graphics

These assume roughly same physical/displayed height and interesting content placement. Height is assumed to be constant, although you might consider 125% of baseline height for sw600 and 150% of baseline height for sw720 to take advantage of the larger screens (adjusting content to fit those heights, of course).

  • res/drawable-xhdpi -> width: 720px
  • res/drawable-land-xhdpi -> width: 1280px
  • res/drawable-sw600dp-xhdpi -> width: 1200px (interesting stuff should be in the middle 720px)
  • res/drawable-sw600dp-land-xhdpi -> width: 1920px (interesting stuff should be in the middle 1280px)
  • res/drawable-sw720dp-xhdpi -> width: 1600px (interesting stuff should be in the middle 720px)
  • res/drawable-sw720dp-land-xhdpi -> width: 2560px (interesting stuff should be in the middle 1280px)

Links

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment