Top Banner
James Montemagno Developer Evangelist, Xamarin @JamesMontemagno Sweeten Up Your Android Apps with Lollipop and Material Design
60

Android Lollipop and Material Design

Jul 16, 2015

Download

Engineering

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Android Lollipop and Material Design

James Montemagno Developer Evangelist, Xamarin @JamesMontemagno

Sweeten Up Your Android Apps with Lollipop and

Material Design

Page 2: Android Lollipop and Material Design

Who’s this guy?

James Montemagno

Developer Evangelist

[email protected] http://motz.codes @JamesMontemagno

Page 3: Android Lollipop and Material Design

Android Lollipop

Page 4: Android Lollipop and Material Design

Android Lollipop Major Features

§  ART Runtime!§  Material Design!§  Widgets, Views, and Shadows!§  Animations!§  Notifications!§  Compatibility!

Page 5: Android Lollipop and Material Design

MaterialDesign

Android L Major Features

google.com/design/spec/material-‐design/introduction.html

Bold, graphic, intentional Material metaphor Motion provides meaning

Page 6: Android Lollipop and Material Design

§  Brand new style for applications.

•  Theme.Material •  Theme.Material.Light •  Theme.Material.Light.

DarkActionBar

Material Design

Page 7: Android Lollipop and Material Design

§  colorPrimary – App Branding Color

§  colorPrimaryDark – Status bar & contextual bars

§  colorAccent – Theme UI Controls (﴾ie. checkbox)﴿

Material Design – Color Palette

Page 8: Android Lollipop and Material Design

Material Design – Color Palette

Page 9: Android Lollipop and Material Design

Let’s Look

Page 10: Android Lollipop and Material Design

§ AppCompat v21 to the Rescue!! § New Themes § New Controls § New Support Libraries

Lollipop Only?

Page 11: Android Lollipop and Material Design

§  Brand new style for applications.

•  Theme.AppCompat •  Theme.AppCompat.Light •  Theme.AppCompat.Light.

DarkActionBar

AppCompat Material Design

Page 12: Android Lollipop and Material Design

App Compat Material Design – Color Palette

Page 13: Android Lollipop and Material Design

§ Google Design Guidelines –  http://www.google.com/design/spec/style/color.html#color-‐color-‐palette

Find Your Theme

Page 14: Android Lollipop and Material Design

§ Material Palette materialpalette.com

Find Your Theme

Page 15: Android Lollipop and Material Design

§ Also use:

– SupportActionBar

Update Activity

Page 16: Android Lollipop and Material Design

§  Extendable & Customizable ActionBar

–  Inherits from ActionBar

§  You can have multiple in your Layout now!

§ Uses the same menu items! § Works with AppCompat

Goodbye ActionBar, Hello Toolbar

Page 17: Android Lollipop and Material Design

Step 1: toolbar.axml

Page 18: Android Lollipop and Material Design

Step 2: Insert into Activity axml

Page 19: Android Lollipop and Material Design

Step 3: Update ActionBarActivity

Page 20: Android Lollipop and Material Design

Step 4: Update Theme

Page 21: Android Lollipop and Material Design

Optional: Additional Toolbars

Add  into  axml  &  FindViewById:  

Page 22: Android Lollipop and Material Design

Complete!

h6p://developer.xamarin.com/samples/monodroid/Supportv7/AppCompat/Toolbar/  

Page 23: Android Lollipop and Material Design

Let’s Look

Page 24: Android Lollipop and Material Design

Xamarin.Forms?

Page 25: Android Lollipop and Material Design

Kind of J

h6ps://github.com/jamesmontemagno/Hanselman.Forms  

Page 26: Android Lollipop and Material Design

Add Style-‐v21 values/styles.xml  

values-­‐v21/styles.xml  

Page 27: Android Lollipop and Material Design

Remove Icon

Page 28: Android Lollipop and Material Design

Update Hamburger Button

MasterDetailPage  -­‐Set  Icon  to  “slideout.png”  or  whatever  you  have  named  it  -­‐Add  default  and  v21  drawables  

Page 29: Android Lollipop and Material Design

Let’s Look

Page 30: Android Lollipop and Material Design

Views and Shadows

§ Palettes § CardView § RecyclerView § Elevation

Android Lollipop Major Features

Page 31: Android Lollipop and Material Design

§  Extract Prominent Colors from Image

§  6 Palettes Generated

Generate a color pallet from an image

Material Design –Palettes

https://www.nuget.org/packages/Xamarin.Android.Support.v7.Palette/

Page 32: Android Lollipop and Material Design

§  Bitmaps as alpha maps §  android:tint=“@color/blue”

Material Design – Drawable Tint

Page 33: Android Lollipop and Material Design

CardView

Wrap any view in a CardView

https://www.nuget.org/packages Xamarin.Android.Support.v7.CardView/

Page 34: Android Lollipop and Material Design

RecyclerView

https://www.nuget.org/packages/Xamarin.Android.Support.v7.RecyclerView/

§ High speed efficient ListView §  Includes layout manager for positioning items § Default animations for common item operations

Page 35: Android Lollipop and Material Design

Elevation

§  android:elevation=“2dp” § View.SetTranslationZ method §  Z = elevation + translationZ

Page 36: Android Lollipop and Material Design

Demo

Page 37: Android Lollipop and Material Design

Animations § Touch Feedback § Reveal § Activity Transitions

Android Lollipop Major Features

Page 38: Android Lollipop and Material Design

Surface reaction

Animation

Page 39: Android Lollipop and Material Design

Surface reaction

Animation

Material response

Page 40: Android Lollipop and Material Design

Surface reaction

Animation

Material response Radial action

Page 41: Android Lollipop and Material Design

§  Default Touch Feedback Animation: RippleDrawable

§  Set Background to: •  ?android:attr/

selectableItemBackground •  ?android:attr/

selectableItemBackgroundBorderless §  Create custom RippleDrawable using

the ripple element

Animation – Touch Feedback

Page 42: Android Lollipop and Material Design

Animation – Reveal

§  Easily create clipping circles

Page 43: Android Lollipop and Material Design

§  Custom animations for enter and exit transitions of activities •  Enter: How views in the activity enter •  Exit: How view in activity exit •  Shared Elements: How views that are shared

between 2 activities animate

Animation – Activity Transitions

Page 44: Android Lollipop and Material Design

Let’s Look

Page 45: Android Lollipop and Material Design

Notifications §  Lock Screen Notifications § Notifications Metadata § Unified Notifications

Android Lollipop Major Features

Page 46: Android Lollipop and Material Design

§ Android.App.Notification.Builder.SetVisibility(﴾)﴿ •  Private: Shows basic information such as icon, but

hides full content •  Public: Show the notification's full content •  Secret: Show nothing, excluding even the

notification’s icon

New APIs – Lock Screen Notifications (﴾Android Lollipop)﴿

Page 47: Android Lollipop and Material Design

§  SetCategory(﴾)﴿: Tells the system how to handle notifications when the device is in Do not Disturb

§  SetPriority(﴾)﴿: Set to Max or High to appear in a small floating window if the sound also has a vibration or sound.

§ AddPerson(﴾)﴿: Add a list of people to notification.

New APIs – Notifications Metadata (﴾Android Lollipop)﴿

Page 48: Android Lollipop and Material Design

Unified Notifications – Standard and Extended

Page 49: Android Lollipop and Material Design

Compatibility& More

§ New APIs § Android Lollipop Small Features § Google Play Services via NuGet

Android Lollipop Major Features

Page 50: Android Lollipop and Material Design

§  Material Theme •  Only available in Android L

Developer Preview o  Define theme that inherits from

older theme (﴾like Holo)﴿ in res/values/styles.xml

o  Define them with same name that inherits from Material in res/values-‐v21/styles.xml

o  Set theme as your app’s theme in manifest file

New APIs – Compatibility

§  Layouts •  Do not use any of the new XML attributes from

Android L Developer Preview, they will not work with previous versions of Android.

•  You must provide alternative layouts if you wish to use them o  L Preview Layouts: res/layout-‐v21/ o  Alternative Layouts: res/layout/ o  Do avoid duplication of code, define styles in

res/values/ o  Modify the style in res/values-‐v21/ for new APIs

Page 51: Android Lollipop and Material Design

§  UI Widgets •  Support v7: RecyclerView & CardView

o  Limitations (﴾pre-‐L Preview)﴿: o  CardView falls back to

programmatic shadows implementation using additional padding

o  CardView does not clip its children that intersect with rounded corners

New APIs – Compatibility

§  Animations •  Following are Android L Developer Preview ONLY:

o  Activity Transitions o  Touch feedback o  Reveal animations o  Path-‐based animations

Page 52: Android Lollipop and Material Design

§  Camera •  Enhanced image and

video capturing. Capture Raw sensor data.

§  Multi-‐networking •  Dynamically scan for

available network with specific capability and automatically connect.

§  BLE Peripheral Mode •  Apps that connect to devices

such as pedometer or health monitor and transfer data to another BLE device.

§  Document-‐Centric Recents §  Job Scheduler

Android L Small Features

Page 53: Android Lollipop and Material Design

Google Play Services via NuGet

§  Play Game Services: event –based challenges, saved games, and game profiles

§  App Indexing API §  Google Cast: Media tracks for closed captioning §  Wallet: Save to Wallet, geo-‐fenced in-‐store notifications,

split tender between wallet & card §  Analytics: Measure product impressions/product clicks §  Mobile Ads: in-‐app purchase ads §  Dynamic Security Provider

Page 54: Android Lollipop and Material Design

Views § Floating Action Button (﴾FAB)﴿ § Page Slider

Android Lollipop – Not Built In

Page 55: Android Lollipop and Material Design

§  https://components.xamarin.com/view/fab

Floating Action Button

Page 56: Android Lollipop and Material Design

§  https://components.xamarin.com/view/PagerSlidingTabStrip

Pager Slider

Page 57: Android Lollipop and Material Design

Demo

Page 58: Android Lollipop and Material Design

Android Recap

•  Android Lollipop •  Material Design •  Views & Animations •  Notifications

• New Templates – https://visualstudiogallery.msdn.microsoft.com/

bee6442f-‐8f5a-‐4bba-‐8849-‐e380b61e76b0 • AppCompat is your new friend

Page 59: Android Lollipop and Material Design

§  Intro to AppCompat & Toolbar!§  http://blog.xamarin.com/android-tips-hello-material-design-v7-appcompat/!§  http://blog.xamarin.com/android-tips-hello-toolbar-goodbye-action-bar/!

§  Android L Documentation!§  http://developer.xamarin.com/guides/android/platform_features/android_l/

introduction_to_android_l/!!

§  Samples!§  http://developer.xamarin.com/samples/android/!

Resources

Page 60: Android Lollipop and Material Design

James Montemagno Developer Evangelist, Xamarin @JamesMontemagno

Thank you! Q & A