SlideShare uma empresa Scribd logo
1 de 41
Baixar para ler offline
Android Design Patterns


           Raul Portales
           @sla_shalafi



           Platty Soft
           @plattysoft
Why?




Good Design = Happy Users
Device Independent Design




Save yourself time and headaches
Device Independent Design
●   Use dips
●   Prefer Relative Layouts
●   Qualify dimensions as resources
       –   Best way to move to tablets
Fragments




 Design for phones and tablets
Reuse as much code as you can
Fragments
●   A Fragment represents a behavior or a portion
    of user interface in an Activity.
●   You can think of a fragment as a modular
    section of an activity, which has its own
    lifecycle, receives its own input events, and
    which you can add or remove while the activity
    is running (sort of like a "sub activity" that you
    can reuse in different activities).
Using Fragments
●   Fragments are only available 3.0+
●   Gingerbread is still on 50%+ of devices
Compat Library




Brings Fragments back to 1.6
Fragments: Detail View
Fragments: Detail View
The tech side
●   MasterFragment
●   DetailFragment
●   Qualify layouts
        –   xlarge-land → 2 fragments
        –   normal → 1 fragment
●   MainActivity
        –   If has a detail fragment, use it
        –   Or write 2 different activities
Fragments
●   onCreateView
●   onViewCreated
●   getActivity
●   getArguments
Common Pitfalls
●   Be aware of the Constructor!!
●   The Activity may not be always there
       –   It may have been destroyed
       –   Or the fragment detached
●   There is no communication among fragments
       –   Do it through the Activity
       –   Better: Use an interface
FragmentManager
●   findFragmentById
●   findFragmentByTag
●   FragmentTransaction


FragmentManager fm = getSupportFragmentManager();
FragmentTransaction ft = fm.beginTransaction();
ft.replace(R.id.mainFragment, MyFragment.newInstance());
ft.commitAllowingStateLoss();
Fragments: View Pager




The most useful utility of Fragments
Fragments: View Pager
The tech side
●   MainActivity
●   FragmentPagerAdapter
       –   Fragments
Show me the Code
 <android.support.v4.view.ViewPager
        android:id="@+id/pager"
        android:layout_width="fill_parent"
        android:layout_height="0px"
        android:layout_weight="1"/>
 </LinearLayout>




ViewPager pager = (ViewPager) findViewById(R.id.pager);
pager.setAdapter(adapter);
Action Bar




Main improvement in 3.0 and 4.0
 Has been around since 2009
Action Bar
●   Provide a dedicated space for identifying the
    application brand and user location.
●   Provide consistent navigation and view
    refinement across different applications.
●   Make key actions for the activity (such as
    "search", "create", "share", etc.) prominent and
    accessible to the user in a predictable way.
Action Bar




1.App icon
2.View control
3.Action buttons
4.Action overflow
Action Buttons
●   Frequent
●   Important
●   Typical
Show me the Code
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.main_activity, menu);
    return true;
}

<menu xmlns:android="...”>
    <item android:id="@+id/menu_save"
        android:icon="@drawable/ic_menu_save"
        android:title="@string/menu_save"
        android:showAsAction="ifRoom|withText" />
</menu>
The Action Bar is NOT part of the Compat Library
ActionBarSherlock
●   Deprecated from Inception
       –   Same class names, different packages
●   Based on the Compat library
●   From Android 2.x up
Using ABS
●   Add ABS as library
●   Use the theme for your App
●   getActionBar → getSupportActionBar
●   Activity → SherlockActivity
●   FragmentActivity → SherlockFragmentActivity
●   Fragment → SherlockFragment
●   And so on...
ViewPageIndicator




You have seen it in the screenshots
   Combined with a ViewPager
ViewPageIndicator
Show me the Code
<com.viewpagerindicator.TitlePageIndicator
     android:id="@+id/indicator"
     android:padding="10dip"
     android:layout_height="wrap_content"
     android:layout_width="fill_parent" />




mIndicator = (TitlePageIndicator)findViewById(R.id.indicator);
mIndicator.setViewPager(pager);
Navigation Styles
●   Top navigation tabs
       –   For a clear landing page
●   Dashboard
       –   For a set of important options
●   Drawer
       –   Combined with a landing page
Navigation Styles




       Vs.
Testing on devices
Testing on devices
Testing on devices
Testing on devices
Doing more with less
●   Gingerbread, hdpi, normal → Nexus One
●   Jelly Bean, xhdpi → Galaxy Nexus
●   Froyo, mdpi → HTC Magic
●   ICS, xlarge → Asus Transformer
●   large → Nexus 7 / Galaxy Tab 7
●   Honeycomb → Galaxy Tab
To know more...
●   Android Design Site:
    http://developer.android.com/design
●   Google I/O videos, specially day 3
    https://developers.google.com/events/io/sessions#android
●   ActionBarSherlock
    http://actionbarsherlock.com/
●   ViewPageIndicator
    http://viewpagerindicator.com/
Android Design Patterns


           Raul Portales
           @sla_shalafi



           Platty Soft
           @plattysoft

Mais conteúdo relacionado

Mais procurados

Android the Agile way
Android the Agile wayAndroid the Agile way
Android the Agile wayAshwin Raghav
 
Supercharge your Android UI
Supercharge your Android UISupercharge your Android UI
Supercharge your Android UIinovex GmbH
 
Flutter state management from zero to hero
Flutter state management from zero to heroFlutter state management from zero to hero
Flutter state management from zero to heroAhmed Abu Eldahab
 
Intro to Flutter
Intro to FlutterIntro to Flutter
Intro to FlutterEason Pai
 
Getting started with flutter
Getting started with flutterGetting started with flutter
Getting started with flutterrihannakedy
 
Google flutter the easy and practical way
Google flutter the easy and practical wayGoogle flutter the easy and practical way
Google flutter the easy and practical wayAhmed Abu Eldahab
 
Support Design Library
Support Design LibrarySupport Design Library
Support Design LibraryTaeho Kim
 
Android Introduction on Java Forum Stuttgart 11
Android Introduction on Java Forum Stuttgart 11 Android Introduction on Java Forum Stuttgart 11
Android Introduction on Java Forum Stuttgart 11 Lars Vogel
 
Dagger in multi module sdk
Dagger in multi module sdkDagger in multi module sdk
Dagger in multi module sdkYoung-Hyuk Yoo
 
Getting Started with Cross-Platform Mobile Development with Flutter and Dart
Getting Started with Cross-Platform Mobile Development with Flutter and DartGetting Started with Cross-Platform Mobile Development with Flutter and Dart
Getting Started with Cross-Platform Mobile Development with Flutter and DartHarshith Keni
 
Top five reasons you should prefer flutter app development
Top five reasons you should prefer flutter app developmentTop five reasons you should prefer flutter app development
Top five reasons you should prefer flutter app developmentSolution Analysts
 
[Alexandria Devfest] the magic of flutter
[Alexandria Devfest] the magic of flutter[Alexandria Devfest] the magic of flutter
[Alexandria Devfest] the magic of flutterAhmed Abu Eldahab
 
Flutter workshop @ bang saen 2020
Flutter workshop @ bang saen 2020Flutter workshop @ bang saen 2020
Flutter workshop @ bang saen 2020Anuchit Chalothorn
 

Mais procurados (20)

Android Study Jams - Info Session
Android Study Jams - Info SessionAndroid Study Jams - Info Session
Android Study Jams - Info Session
 
Flutter - DevFestDC
Flutter - DevFestDCFlutter - DevFestDC
Flutter - DevFestDC
 
Introduction to Flutter
Introduction to FlutterIntroduction to Flutter
Introduction to Flutter
 
Type of angular 2
Type of angular 2Type of angular 2
Type of angular 2
 
Flutter
FlutterFlutter
Flutter
 
Android the Agile way
Android the Agile wayAndroid the Agile way
Android the Agile way
 
Supercharge your Android UI
Supercharge your Android UISupercharge your Android UI
Supercharge your Android UI
 
Flutter state management from zero to hero
Flutter state management from zero to heroFlutter state management from zero to hero
Flutter state management from zero to hero
 
Intro to Flutter
Intro to FlutterIntro to Flutter
Intro to Flutter
 
Getting started with flutter
Getting started with flutterGetting started with flutter
Getting started with flutter
 
Flutter vs not flutter
Flutter vs not flutterFlutter vs not flutter
Flutter vs not flutter
 
Google flutter the easy and practical way
Google flutter the easy and practical wayGoogle flutter the easy and practical way
Google flutter the easy and practical way
 
Support Design Library
Support Design LibrarySupport Design Library
Support Design Library
 
Android Introduction on Java Forum Stuttgart 11
Android Introduction on Java Forum Stuttgart 11 Android Introduction on Java Forum Stuttgart 11
Android Introduction on Java Forum Stuttgart 11
 
Dagger in multi module sdk
Dagger in multi module sdkDagger in multi module sdk
Dagger in multi module sdk
 
Getting Started with Cross-Platform Mobile Development with Flutter and Dart
Getting Started with Cross-Platform Mobile Development with Flutter and DartGetting Started with Cross-Platform Mobile Development with Flutter and Dart
Getting Started with Cross-Platform Mobile Development with Flutter and Dart
 
Top five reasons you should prefer flutter app development
Top five reasons you should prefer flutter app developmentTop five reasons you should prefer flutter app development
Top five reasons you should prefer flutter app development
 
[Alexandria Devfest] the magic of flutter
[Alexandria Devfest] the magic of flutter[Alexandria Devfest] the magic of flutter
[Alexandria Devfest] the magic of flutter
 
Hello Flutter
Hello FlutterHello Flutter
Hello Flutter
 
Flutter workshop @ bang saen 2020
Flutter workshop @ bang saen 2020Flutter workshop @ bang saen 2020
Flutter workshop @ bang saen 2020
 

Semelhante a Android design patterns

Android development - the basics, MFF UK, 2012
Android development - the basics, MFF UK, 2012Android development - the basics, MFF UK, 2012
Android development - the basics, MFF UK, 2012Tomáš Kypta
 
Milos Marinkovic "Modular Android UI"
Milos Marinkovic "Modular Android UI"Milos Marinkovic "Modular Android UI"
Milos Marinkovic "Modular Android UI"IT Event
 
Fragmentation in android
Fragmentation in android Fragmentation in android
Fragmentation in android Esraa El Ghoul
 
Lecture #4 activities &amp; fragments
Lecture #4  activities &amp; fragmentsLecture #4  activities &amp; fragments
Lecture #4 activities &amp; fragmentsVitali Pekelis
 
Android - Open Source Bridge 2011
Android - Open Source Bridge 2011Android - Open Source Bridge 2011
Android - Open Source Bridge 2011sullis
 
Dori waldman android _course
Dori waldman android _courseDori waldman android _course
Dori waldman android _courseDori Waldman
 
Dori waldman android _course_2
Dori waldman android _course_2Dori waldman android _course_2
Dori waldman android _course_2Dori Waldman
 
Designing and implementing_android_uis_for_phones_and_tablets
Designing and implementing_android_uis_for_phones_and_tabletsDesigning and implementing_android_uis_for_phones_and_tablets
Designing and implementing_android_uis_for_phones_and_tabletsTeddy Koornia
 
Lecture #3 activities and intents
Lecture #3  activities and intentsLecture #3  activities and intents
Lecture #3 activities and intentsVitali Pekelis
 
Android N Highligts
Android N HighligtsAndroid N Highligts
Android N HighligtsSercan Yusuf
 
Google I/O 2019 - what's new in Android Q and Jetpack
Google I/O 2019 - what's new in Android Q and JetpackGoogle I/O 2019 - what's new in Android Q and Jetpack
Google I/O 2019 - what's new in Android Q and JetpackSunita Singh
 
Introducing Honeycomb
Introducing HoneycombIntroducing Honeycomb
Introducing HoneycombCommonsWare
 
Introduction to Honeycomb APIs - Android Developer Lab 2011 Q3
Introduction to Honeycomb APIs - Android Developer Lab 2011 Q3Introduction to Honeycomb APIs - Android Developer Lab 2011 Q3
Introduction to Honeycomb APIs - Android Developer Lab 2011 Q3Paris Android User Group
 
Android Jump Start
Android Jump StartAndroid Jump Start
Android Jump StartConFoo
 
Mobile html5 today
Mobile html5 todayMobile html5 today
Mobile html5 todayIdo Green
 

Semelhante a Android design patterns (20)

Android development - the basics, MFF UK, 2012
Android development - the basics, MFF UK, 2012Android development - the basics, MFF UK, 2012
Android development - the basics, MFF UK, 2012
 
Milos Marinkovic "Modular Android UI"
Milos Marinkovic "Modular Android UI"Milos Marinkovic "Modular Android UI"
Milos Marinkovic "Modular Android UI"
 
Fragmentation in android
Fragmentation in android Fragmentation in android
Fragmentation in android
 
Lecture #4 activities &amp; fragments
Lecture #4  activities &amp; fragmentsLecture #4  activities &amp; fragments
Lecture #4 activities &amp; fragments
 
Android Made Simple
Android Made SimpleAndroid Made Simple
Android Made Simple
 
Android - Open Source Bridge 2011
Android - Open Source Bridge 2011Android - Open Source Bridge 2011
Android - Open Source Bridge 2011
 
Dori waldman android _course
Dori waldman android _courseDori waldman android _course
Dori waldman android _course
 
Dori waldman android _course_2
Dori waldman android _course_2Dori waldman android _course_2
Dori waldman android _course_2
 
Designing and implementing_android_uis_for_phones_and_tablets
Designing and implementing_android_uis_for_phones_and_tabletsDesigning and implementing_android_uis_for_phones_and_tablets
Designing and implementing_android_uis_for_phones_and_tablets
 
Lecture #3 activities and intents
Lecture #3  activities and intentsLecture #3  activities and intents
Lecture #3 activities and intents
 
Android N Highligts
Android N HighligtsAndroid N Highligts
Android N Highligts
 
Google I/O 2019 - what's new in Android Q and Jetpack
Google I/O 2019 - what's new in Android Q and JetpackGoogle I/O 2019 - what's new in Android Q and Jetpack
Google I/O 2019 - what's new in Android Q and Jetpack
 
Introducing Honeycomb
Introducing HoneycombIntroducing Honeycomb
Introducing Honeycomb
 
Fragment
Fragment Fragment
Fragment
 
Multi screenlab
Multi screenlabMulti screenlab
Multi screenlab
 
Lesson 4
Lesson 4Lesson 4
Lesson 4
 
Introduction to Honeycomb APIs - Android Developer Lab 2011 Q3
Introduction to Honeycomb APIs - Android Developer Lab 2011 Q3Introduction to Honeycomb APIs - Android Developer Lab 2011 Q3
Introduction to Honeycomb APIs - Android Developer Lab 2011 Q3
 
Android Jump Start
Android Jump StartAndroid Jump Start
Android Jump Start
 
Mobile html5 today
Mobile html5 todayMobile html5 today
Mobile html5 today
 
Android dev
Android devAndroid dev
Android dev
 

Mais de Platty Soft

Integrating Google Play Games
Integrating Google Play GamesIntegrating Google Play Games
Integrating Google Play GamesPlatty Soft
 
The Indie Game Developer Survival Guide
The Indie Game Developer Survival GuideThe Indie Game Developer Survival Guide
The Indie Game Developer Survival GuidePlatty Soft
 
Continuous integration for Android
Continuous integration for AndroidContinuous integration for Android
Continuous integration for AndroidPlatty Soft
 
Tools for developing Android Games
 Tools for developing Android Games Tools for developing Android Games
Tools for developing Android GamesPlatty Soft
 
Road to Publishing
Road to PublishingRoad to Publishing
Road to PublishingPlatty Soft
 

Mais de Platty Soft (6)

Integrating Google Play Games
Integrating Google Play GamesIntegrating Google Play Games
Integrating Google Play Games
 
The Indie Game Developer Survival Guide
The Indie Game Developer Survival GuideThe Indie Game Developer Survival Guide
The Indie Game Developer Survival Guide
 
Continuous integration for Android
Continuous integration for AndroidContinuous integration for Android
Continuous integration for Android
 
Piracy on Apps
Piracy on AppsPiracy on Apps
Piracy on Apps
 
Tools for developing Android Games
 Tools for developing Android Games Tools for developing Android Games
Tools for developing Android Games
 
Road to Publishing
Road to PublishingRoad to Publishing
Road to Publishing
 

Android design patterns

  • 1. Android Design Patterns Raul Portales @sla_shalafi Platty Soft @plattysoft
  • 2. Why? Good Design = Happy Users
  • 3. Device Independent Design Save yourself time and headaches
  • 4.
  • 5. Device Independent Design ● Use dips ● Prefer Relative Layouts ● Qualify dimensions as resources – Best way to move to tablets
  • 6. Fragments Design for phones and tablets Reuse as much code as you can
  • 7. Fragments ● A Fragment represents a behavior or a portion of user interface in an Activity. ● You can think of a fragment as a modular section of an activity, which has its own lifecycle, receives its own input events, and which you can add or remove while the activity is running (sort of like a "sub activity" that you can reuse in different activities).
  • 8. Using Fragments ● Fragments are only available 3.0+ ● Gingerbread is still on 50%+ of devices
  • 12. The tech side ● MasterFragment ● DetailFragment ● Qualify layouts – xlarge-land → 2 fragments – normal → 1 fragment ● MainActivity – If has a detail fragment, use it – Or write 2 different activities
  • 13. Fragments ● onCreateView ● onViewCreated ● getActivity ● getArguments
  • 14. Common Pitfalls ● Be aware of the Constructor!! ● The Activity may not be always there – It may have been destroyed – Or the fragment detached ● There is no communication among fragments – Do it through the Activity – Better: Use an interface
  • 15. FragmentManager ● findFragmentById ● findFragmentByTag ● FragmentTransaction FragmentManager fm = getSupportFragmentManager(); FragmentTransaction ft = fm.beginTransaction(); ft.replace(R.id.mainFragment, MyFragment.newInstance()); ft.commitAllowingStateLoss();
  • 16. Fragments: View Pager The most useful utility of Fragments
  • 18. The tech side ● MainActivity ● FragmentPagerAdapter – Fragments
  • 19. Show me the Code <android.support.v4.view.ViewPager android:id="@+id/pager" android:layout_width="fill_parent" android:layout_height="0px" android:layout_weight="1"/> </LinearLayout> ViewPager pager = (ViewPager) findViewById(R.id.pager); pager.setAdapter(adapter);
  • 20. Action Bar Main improvement in 3.0 and 4.0 Has been around since 2009
  • 21. Action Bar ● Provide a dedicated space for identifying the application brand and user location. ● Provide consistent navigation and view refinement across different applications. ● Make key actions for the activity (such as "search", "create", "share", etc.) prominent and accessible to the user in a predictable way.
  • 22. Action Bar 1.App icon 2.View control 3.Action buttons 4.Action overflow
  • 23. Action Buttons ● Frequent ● Important ● Typical
  • 24. Show me the Code public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.main_activity, menu); return true; } <menu xmlns:android="...”> <item android:id="@+id/menu_save" android:icon="@drawable/ic_menu_save" android:title="@string/menu_save" android:showAsAction="ifRoom|withText" /> </menu>
  • 25. The Action Bar is NOT part of the Compat Library
  • 26.
  • 27. ActionBarSherlock ● Deprecated from Inception – Same class names, different packages ● Based on the Compat library ● From Android 2.x up
  • 28. Using ABS ● Add ABS as library ● Use the theme for your App ● getActionBar → getSupportActionBar ● Activity → SherlockActivity ● FragmentActivity → SherlockFragmentActivity ● Fragment → SherlockFragment ● And so on...
  • 29. ViewPageIndicator You have seen it in the screenshots Combined with a ViewPager
  • 31. Show me the Code <com.viewpagerindicator.TitlePageIndicator android:id="@+id/indicator" android:padding="10dip" android:layout_height="wrap_content" android:layout_width="fill_parent" /> mIndicator = (TitlePageIndicator)findViewById(R.id.indicator); mIndicator.setViewPager(pager);
  • 32. Navigation Styles ● Top navigation tabs – For a clear landing page ● Dashboard – For a set of important options ● Drawer – Combined with a landing page
  • 38. Doing more with less ● Gingerbread, hdpi, normal → Nexus One ● Jelly Bean, xhdpi → Galaxy Nexus ● Froyo, mdpi → HTC Magic ● ICS, xlarge → Asus Transformer ● large → Nexus 7 / Galaxy Tab 7 ● Honeycomb → Galaxy Tab
  • 39. To know more... ● Android Design Site: http://developer.android.com/design ● Google I/O videos, specially day 3 https://developers.google.com/events/io/sessions#android ● ActionBarSherlock http://actionbarsherlock.com/ ● ViewPageIndicator http://viewpagerindicator.com/
  • 40.
  • 41. Android Design Patterns Raul Portales @sla_shalafi Platty Soft @plattysoft