Android Fragments

  • 7,125 views
Uploaded on

Some categories of the Android Market seem to provide an almost endless choice of applications and standing out there requires more than just having the right mix of features. This talk will provide …

Some categories of the Android Market seem to provide an almost endless choice of applications and standing out there requires more than just having the right mix of features. This talk will provide ideas, tips, and code samples for making Android User interfaces more intuitive, attractive, and fun to use.

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
7,125
On Slideshare
0
From Embeds
0
Number of Embeds
7

Actions

Shares
Downloads
73
Comments
0
Likes
1

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. android - UIfor phones and tablets Copyright © 2011-2012, Wolf Paulus - http://wolfpaulus.com - A Tech Casita Production. All rights reserved.
  • 2. Copyright © 2011-2012, Wolf Paulus - http://wolfpaulus.com - A Tech Casita Production. All rights reserved.
  • 3. Fragmentation Form Factor Screen Size DensityCopyright © 2011-2012, Wolf Paulus - http://wolfpaulus.com - A Tech Casita Production. All rights reserved.
  • 4. Copyright © 2011-2012, Wolf Paulus - http://wolfpaulus.com - A Tech Casita Production. All rights reserved.
  • 5. Cupcake 1.5 Donut 1.6 Eclair 2.1 Froyo 2.2 Gingerbread 2.3 Gingerbread 2.3 39% Honeycomb 3.0 Honeycomb 3.1 Honeycomb 3.2 Honeycomb 3.0 Honeycomb 3.1 0% Honeycomb 3.2 1% 1% Cupcake 1.5 1% Donut 1.6 1%Froyo 2.2 Eclair 2.1 45% 12%Copyright © 2011-2012, Wolf Paulus - http://wolfpaulus.com - A Tech Casita Production. All rights reserved.
  • 6. FragmentationForm Factor Screen Size DensityCopyright © 2011-2012, Wolf Paulus - http://wolfpaulus.com - A Tech Casita Production. All rights reserved.
  • 7. worldwide android sales to end users • in Q2 2011: 46,775,900 • More than 500,000 Android Devices per Day • More than 9,000 Tablets per DayCopyright © 2011-2012, Wolf Paulus - http://wolfpaulus.com - A Tech Casita Production. All rights reserved. source: http://www.gartner.com/it/page.jsp?id=1764714
  • 8. Fragmentation Form Factor Screen Size DensityCopyright © 2011-2012, Wolf Paulus - http://wolfpaulus.com - A Tech Casita Production. All rights reserved.
  • 9. Copyright © 2011-2012, Wolf Paulus - http://wolfpaulus.com - A Tech Casita Production. All rights reserved.
  • 10. small normal large xlargeCopyright © 2011-2012, Wolf Paulus - http://wolfpaulus.com - A Tech Casita Production. All rights reserved.
  • 11. Fragmentation Form Factor Screen SizeDensityCopyright © 2011-2012, Wolf Paulus - http://wolfpaulus.com - A Tech Casita Production. All rights reserved.
  • 12. low dpi medium dpi high dpi extra high dpi 120 160 240 320Copyright © 2011-2012, Wolf Paulus - http://wolfpaulus.com - A Tech Casita Production. All rights reserved.
  • 13. Same image renders bigger on low dpi low dpi high dpi Copyright © 2011-2012, Wolf Paulus - http://wolfpaulus.com - A Tech Casita Production. All rights reserved.
  • 14. Copyright © 2011-2012, Wolf Paulus - http://wolfpaulus.com - A Tech Casita Production. All rights reserved.
  • 15. ldpi mdpi hdpi xhdpiCopyright © 2011-2012, Wolf Paulus - http://wolfpaulus.com - A Tech Casita Production. All rights reserved.
  • 16. http://android-ui-utils.googlecode.com/hg/asset-studio/dist/index.html Copyright © 2011-2012, Wolf Paulus - http://wolfpaulus.com - A Tech Casita Production. All rights reserved.
  • 17. Copyright © 2011-2012, Wolf Paulus - http://wolfpaulus.com - A Tech Casita Production. All rights reserved.
  • 18. Copyright © 2011-2012, Wolf Paulus - http://wolfpaulus.com - A Tech Casita Production. All rights reserved.
  • 19. optimizing for form factor & orientationCopyright © 2011-2012, Wolf Paulus - http://wolfpaulus.com - A Tech Casita Production. All rights reserved.
  • 20. Copyright © 2011-2012, Wolf Paulus - http://wolfpaulus.com - A Tech Casita Production. All rights reserved.
  • 21. Contacts Details WebView Activity Activity ActivityCopyright © 2011-2012, Wolf Paulus - http://wolfpaulus.com - A Tech Casita Production. All rights reserved.
  • 22. demo and code© 2011 Wolf Paulus http://wolfpaulus.com Paulus - http://wolfpaulus.com - A Tech Casita Production. All rights reserved. Copyright © 2011-2012, Wolf
  • 23. Contacts Details WebView Activity Activity ActivityCopyright © 2011-2012, Wolf Paulus - http://wolfpaulus.com - A Tech Casita Production. All rights reserved.
  • 24. ContactsActivityDetails WebViewActivity Activity Copyright © 2011-2012, Wolf Paulus - http://wolfpaulus.com - A Tech Casita Production. All rights reserved.
  • 25. FragmentsCopyright © 2011-2012, Wolf Paulus - http://wolfpaulus.com - A Tech Casita Production. All rights reserved.
  • 26. onAttachCalled when the fragment hasbeen associated with the activity Copyright © 2011-2012, Wolf Paulus - http://wolfpaulus.com - A Tech Casita Production. All rights reserved.
  • 27. onCreateViewThe system calls this when itstime for the fragment to draw itsuser interface for the first time....return a View from this methodthat is the root of the fragmentslayout Copyright © 2011-2012, Wolf Paulus - http://wolfpaulus.com - A Tech Casita Production. All rights reserved.
  • 28. Copyright © 2011-2012, Wolf Paulus - http://wolfpaulus.com - A Tech Casita Production. All rights reserved.
  • 29. layout-land Contacts Details Details WebView Activity Fragment Activity Fragmentlayout Contacts Details WebView Activity Activity Activity Details WebView Fragment Fragment Copyright © 2011-2012, Wolf Paulus - http://wolfpaulus.com - A Tech Casita Production. All rights reserved.
  • 30. Strategy1. add support library into build path: /extras/android/compatibility/v4/android-support-v4.jar2. extend FragmentActivity instead of Activity3. move most of the Activity’s logic into Fragment(s)4. create new layouts containing the Frament declaration and load it in the FragmentActivity’s onCreate()5. Remember: Separation of Concerns / Re-usability Copyright © 2011-2012, Wolf Paulus - http://wolfpaulus.com - A Tech Casita Production. All rights reserved.
  • 31. new source fileslayout-land Contacts Details Details WebView Activity Fragment Activity Fragment new layout declarationlayout Contacts Details WebView Activity Activity Activity Details WebView Fragment Fragment Copyright © 2011-2012, Wolf Paulus - http://wolfpaulus.com - A Tech Casita Production. All rights reserved.
  • 32. before ... ... after Text Copyright © 2011-2012, Wolf Paulus - http://wolfpaulus.com - A Tech Casita Production. All rights reserved.
  • 33. demo and codeCopyright © 2011-2012, Wolf Paulus - http://wolfpaulus.com - A Tech Casita Production. All rights reserved.
  • 34. Contacts Details WebView Activity Activity ActivityCopyright © 2011-2012, Wolf Paulus - http://wolfpaulus.com - A Tech Casita Production. All rights reserved.
  • 35. layout-land Contacts Details Details WebView Activity Fragment Activity Fragmentlayout Contacts Details WebView Activity Activity Activity Details WebView Fragment Fragment Copyright © 2011-2012, Wolf Paulus - http://wolfpaulus.com - A Tech Casita Production. All rights reserved.
  • 36. Copyright © 2011-2012, Wolf Paulus - http://wolfpaulus.com - A Tech Casita Production. All rights reserved.
  • 37. layout-land Contacts Fragment Contacts WebView Activity Fragment Details Fragmentlayout Contacts Details WebView Activity Activity Activity Contacts Details WebView Fragment Fragment Fragment Copyright © 2011-2012, Wolf Paulus - http://wolfpaulus.com - A Tech Casita Production. All rights reserved.
  • 38. code ... Copyright © 2011-2012, Wolf Paulus - http://wolfpaulus.com - A Tech Casita Production. All rights reserved.
  • 39. summaryUse different Layouts to support multiple screen sizesUse different icon sizes to support multiple densitiesUse Fragments to support eXtra large screens / tablets Contacts FragmentContacts Details WebView Contacts WebViewActivity Activity Activity Activity Fragment Details Fragment Copyright © 2011-2012, Wolf Paulus - http://wolfpaulus.com - A Tech Casita Production. All rights reserved.
  • 40. summary Contacts FragmentContacts Details WebView Contacts WebViewActivity Activity Activity Activity Fragment Details Fragment Slides http://wolfpaulus.com/about Code http://wolfpaulus.com/about Copyright © 2011-2012, Wolf Paulus - http://wolfpaulus.com - A Tech Casita Production. All rights reserved.
  • 41. Thanks for coming http://wolfpaulus.comCopyright © 2011-2012, Wolf Paulus - http://wolfpaulus.com - A Tech Casita Production. All rights reserved.