xamarin evolve 2014 - designing android uis for the ever changing device landscape

115
Designing Android UIs for the Ever Changing Device Landscape @michaelstonis Michael Stonis Eight-Bot, Inc.

Upload: mstonis

Post on 01-Jul-2015

380 views

Category:

Software


0 download

DESCRIPTION

Android is everywhere. Developers can now build apps that run on phones, tablets, TVs, cars, wearables, and even appliances! While this provides a breadth of opportunity, it creates a big problem when designing apps that can run across all of these different device types. In this session, join Michael Stonis to talk about how to create and manage dynamic UIs for Xamarin Android apps that look and feel great across different screen sizes and form factors. Presentation Video: http://youtu.be/2k2SMiH37eg

TRANSCRIPT

Page 1: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

Designing Android UIs for the Ever Changing

Device Landscape

@michaelstonis

Michael StonisEight-Bot, Inc.

Page 2: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape
Page 3: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

0

3,333

6,667

10,000

13,333

16,667

20,000

2012 2013 2014

Unique Android Devices

Open Signal, August 2014

Page 4: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

Subtitle

Page 5: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

Big OpportunityWhere do we get started?

Page 6: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

Big Opportunity

■ Design Fundamentals

Where do we get started?

Page 7: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

Big Opportunity

■ Design Fundamentals

Where do we get started?

Page 8: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

Big Opportunity

■ Design Fundamentals

■ Layout Management

Where do we get started?

Page 9: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

Big Opportunity

■ Design Fundamentals

■ Layout Management

Where do we get started?

Page 10: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

Big Opportunity

■ Design Fundamentals

■ Layout Management

■ Android Fragments

Where do we get started?

Page 11: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

Design Fundamentals

Page 12: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

The Big Three

Screen Size Pixel DensityOrientation

Page 13: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

The Big Three

Screen Size Pixel DensityOrientation

Page 14: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

The Big Three

Screen Size Pixel DensityOrientation

Page 15: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

The Big Three

Screen Size Pixel DensityOrientation

Page 16: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

Density Independent Pixels

Page 17: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape
Page 18: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape
Page 19: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape
Page 20: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape
Page 21: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

Density Independent Pixel (DIP)

■ Represents a single pixel on a 160 dpi screen

■ Scales on screens with higher or lower density

■ Use as a standard unit of measurement for layouts and drawables

■ Avoid Using Pixels Like the Plague!

DPI Pixels Per DIP

160

320

Page 22: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

BAD GOOD

Page 23: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

Density Independent Pixel

160 dpi MDPI 1x

320 dpi XHDPI 2x

480 dpi XXHDPI 3x

Page 24: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

Density Independent Pixel

160 dpi MDPI 1x

320 dpi XHDPI 2x

480 dpi XXHDPI 3x

Page 25: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

Density Independent Pixel

160 dpi MDPI 1x

320 dpi XHDPI 2x

480 dpi XXHDPI 3x

Page 26: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

Density Independent Pixels

Page 27: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

Pixels Density Independent Pixels

Page 28: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

Pixels Density Independent Pixels

Page 29: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

Density Independent Pixels

Nexus 5

1920 x 1080 px

Page 30: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

Density Independent Pixels

Nexus 5

1920 x 1080 px

445 dpi

Page 31: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

Density Independent Pixels

Nexus 5

1920 x 1080 px

445 dpi

1 inch

445 pixels

Page 32: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

Calculating DIPs

Resolution (px) x 160 dpiDIP =

Page 33: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

Density Independent Pixels

Nexus 5

1920 x 1080 px

445 dpi

690 x 388 dp

1920 px X 160 445 dpi690 Vertical =

1080 px X 160 445 dpi388 Horizontal =

Page 34: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

Density Independent Pixels

Nexus 5

1920 x 1080 px

445 dpi

690 x 388 dp

1920 px X 160 445 dpi690 Vertical =

1080 px X 160 445 dpi388 Horizontal =

Page 35: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

Density Independent Pixels

Nexus 5

1920 x 1080 px

445 dpi

690 x 388 dp

1920 px X 160 445 dpi690 Vertical =

1080 px X 160 445 dpi388 Horizontal =

Page 36: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

Density Independent Pixel

160 dpi MDPI 1x

240 dpi HDPI 1.5x

320 dpi XHDPI 2x

480 dpi XXHDPI 3x

Page 37: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

Density Independent Pixels

1920 px X 160 480 dpi640 Vertical =

1080 px X 160 480 dpi360 Horizontal =

Nexus 5

1920 x 1080 px

445 dpi

640 x 360 dp

Page 38: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

Device Comparison

Nexus 5

1920 x 1080 px

445 dpi

640 x 360 dp

Nexus 4

1280 x 768 px

318 dpi

640 x 384 dp

Page 39: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

Device Comparison

Nexus 5

1920 x 1080 px

445 dpi

640 x 360 dp

Nexus 4

1280 x 768 px

318 dpi

640 x 384 dp

Page 40: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

Device Comparison

Nexus 4

1280 x 768 px

318 dpi

640 x 384 dp

Nexus 5

1920 x 1080 px

445 dpi

640 x 360 dp

Page 41: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape
Page 42: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape
Page 43: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape
Page 44: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

Scale Independent Pixels (SIP)

■ Use this when specifying sizes for fonts

■ Will scale depending on the device’s pixel density similar to a DIP

■ Scales appropriately to the user’s font size preferences

Scaling for Fonts

Page 45: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

Android Resource Qualifiers

Page 46: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

Android Resource Qualifiers

• Provides us the ability to use different resources for different configurations

• Qualifiers Apply to Resource Folders ■ drawable ■ layout ■ etc.

• Do not apply to resources directly

Different Strokes for Different Folks

Page 47: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

Android Resource QualifiersQualifier Format

<resource type>-<qualifier>

Page 48: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

Android Resource QualifiersExample

layout-landA layout resource in landscape orientation

Page 49: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

Android Resource QualifiersExample

drawable-large-xhdpiA drawable resource on a large screen size with an Extra-high-density screen

Page 50: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

Android Resource Qualifiers

• Region & Language ■ Mobile Country Code (MCC) ■ Language and Language Region

• Device Configuration ■ Portrait ■ Landscape

Resource Qualifier Types

• Device Size Resolution ■ Screen Size ■ Pixel Density

• Device Features ■ UI Mode ■ Hardware Software Keyboard

Page 51: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

bit.ly/1toKVDFAndroid Resource Qualifiers

Page 52: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

Android Resource Qualifiers

• Provides us the ability to use different resources for different configurations

• Qualifiers Apply to Resource Folders ■ drawable ■ layout ■ etc.

• Do not apply to resources directly

Different Strokes for Different Folks

Page 53: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

Density Independent Pixel

160 dpi MDPI 1x

240 dpi HDPI 1.5x

480 dpi XXHDPI 3x

?

Page 54: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

Density Independent Pixel

160 dpi MDPI 1x

240 dpi HDPI 1.5x

480 dpi XXHDPI 3x

?

Page 55: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

Layout Management

Page 56: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

• Full WYSIWYG Editor for Android ■ Control Management ■ Document Explorer ■ XML Editor

• Layouts are standard Android

• Supports Editing Multiple Layouts

Layout ManagementXamarin Android Designer

Page 57: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

Layout ManagementMultiple Layouts

Page 58: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

Demo

Page 59: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="com.xamarin.university.mobilenav.android"> <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="14" /> <application android:icon="@drawable/ic_launcher" android:label="ActionBar Tabs"> </application> <supports-screens android:compatibleWidthLimitDp="integer"/></manifest>

Layout Management

Page 60: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

Fragments

Page 61: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape
Page 62: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape
Page 63: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape
Page 64: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

Android Fragments

• Reusable User-Interface components

• Conceptually similar to an Activity with its own lifecycle and layout

• Create in XML or programmatically

Application Building Blocks

Page 65: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

Android Fragment Creationpublic class FragmentToAdd : Fragment{ public override void OnCreate (Bundle savedInstanceState) { } public override View OnCreateView (LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { } public override void OnPause () { } }

Page 66: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

Android Fragment Key Lifecycle Methodspublic class FragmentToAdd : Fragment{ public override void OnCreate (Bundle savedInstanceState) { } public override View OnCreateView (LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { } public override void OnPause () { } }

Page 67: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

12:00

12:00

12:00

Dialog List Preferences

Page 68: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

12:00

12:00

12:00

Dialog List Preferences

Page 69: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

12:00

12:00

12:00

Dialog List Preferences

Page 70: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

12:00

12:00

12:00

Dialog List Preferences

Page 71: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

Adding a Fragment

Page 72: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

12:00

Page 73: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

12:00

Page 74: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

12:00

Page 75: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

Adding Android Fragments via XML<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:minWidth="25px" android:minHeight="25px"> <fragment class="fragments.NavigationFragment" android:id="@+id/navigation" android:layout_width="fill_parent" android:layout_height="fill_parent" /> </LinearLayout>

Page 76: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

Adding Android Fragments via Codeusing (var transaction = FragmentManager.BeginTransaction()){ transaction.Add(Resource.Id.container, new FragmentToAdd()); transaction.Commit();}

Page 77: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

Adding Android Fragments via Codeusing (var transaction = FragmentManager.BeginTransaction()){ transaction.Add(Resource.Id.container, new FragmentToAdd()); transaction.Commit();}

Page 78: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

Adding Android Fragments via Codeusing (var transaction = FragmentManager.BeginTransaction()){ transaction.Add(Resource.Id.container, new FragmentToAdd()); transaction.Commit();}

Page 79: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

Fragment Manager■ Provides Fragment Discovery

- FindFragmentById and FindFragmentByTag

■ Manage Fragment Navigation History

■ Creation of Transactions

Page 80: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

Adding Android Fragments via Codeusing (var transaction = FragmentManager.BeginTransaction()){ transaction.Add(Resource.Id.container, new FragmentToAdd()); transaction.Commit();}

Page 81: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

Adding Android Fragments via Codeusing (var transaction = FragmentManager.BeginTransaction()){ transaction.Add(Resource.Id.container, new FragmentToAdd()); transaction.Commit();}

Page 82: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

Adding Android Fragments via Codeusing (var transaction = FragmentManager.BeginTransaction()){ transaction.Add(Resource.Id.container, new FragmentToAdd()); transaction.Commit();}

Page 83: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

Fragment Transactions■ Facilitates one-to-many fragment changes

■ Conceptually similar to database transactions

■ Can Create, Replace and Remove Fragments

Page 84: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

Adding Android Fragments via Codeusing (var transaction = FragmentManager.BeginTransaction()){ transaction.Add(Resource.Id.container, new FragmentToAdd()); transaction.Commit();}

Page 85: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

Adding Android Fragments via Codeusing (var transaction = FragmentManager.BeginTransaction()){ transaction.Add(Resource.Id.container, new FragmentToAdd()); transaction.Commit();}

Page 86: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

Adding Android Fragments via Codeusing (var transaction = FragmentManager.BeginTransaction()){ transaction.Add(Resource.Id.container, new FragmentToAdd()); transaction.Commit();}

Page 87: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

Adding Android Fragments via Code<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <FrameLayout android:minWidth="25px" android:minHeight="25px" android:layout_width="match_parent" android:layout_height="0dp" android:id="@+id/container" android:layout_weight="1" />

Page 88: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

Adding Android Fragments via Codeusing (var transaction = FragmentManager.BeginTransaction()){ transaction.Add(Resource.Id.container, new FragmentToAdd()); transaction.Commit();}

Page 89: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

12:00

Page 90: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

12:00

Page 91: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

12:00

Page 92: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

12:00

Page 93: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

12:00

Page 94: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

12:00

Page 95: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

Replacing Android Fragmentsusing (var transaction = FragmentManager.BeginTransaction()){ transaction.SetCustomAnimations( Android.Resource.Animator.FadeIn, Android.Resource.Animator.FadeOut); transaction.Replace(Resource.Id.container, new FragmentToAdd()); transaction.Commit();}

Page 96: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

Communicating with Fragments

Page 97: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

Build for Modularity

• Assume that the Activity knows nothing about your Fragment and vice-versa

• Build knowing that it will be reused and used in varying different contexts

• Make it easy for your Fragment to discover host Activity Functionality

Think like Building Blocks

Page 98: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

Providing Data to a Fragmentvar fragmentToAdd = new FragmentToAdd { Arguments = new Bundle () }; fragmentToAdd.Arguments.PutInt (ArgumentBackgroundColorRed, backgroundColor.R);fragmentToAdd.Arguments.PutInt (ArgumentBackgroundColorGreen, backgroundColor.G);fragmentToAdd.Arguments.PutInt (ArgumentBackgroundColorBlue, backgroundColor.B);

Page 99: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

Guaranteeing Fragment Receives Datapublic static FragmentToAdd BuildFragmentToAdd (Color backgroundColor) { var fragmentToAdd = new FragmentToAdd { Arguments = new Bundle () } ; fragmentToAdd.Arguments.PutInt (ArgumentBackgroundColorRed, backgroundColor.R); fragmentToAdd.Arguments.PutInt (ArgumentBackgroundColorGreen, backgroundColor.G); fragmentToAdd.Arguments.PutInt (ArgumentBackgroundColorBlue, backgroundColor.B); return fragmentToAdd; }

Page 100: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

Guaranteeing Fragment Receives Datapublic static FragmentToAdd BuildFragmentToAdd (Color backgroundColor) { var fragmentToAdd = new FragmentToAdd { Arguments = new Bundle () } ; fragmentToAdd.Arguments.PutInt (ArgumentBackgroundColorRed, backgroundColor.R); fragmentToAdd.Arguments.PutInt (ArgumentBackgroundColorGreen, backgroundColor.G); fragmentToAdd.Arguments.PutInt (ArgumentBackgroundColorBlue, backgroundColor.B); return fragmentToAdd; }

Page 101: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

• Create an Interface that defines any external functionality your fragment needs

• Implement the Interface in your Activity

• In the fragment, check if the Activity has implemented the Interface and make use of any defined functionality

Messaging with the Host ActivityPassing notes in class is okay

Page 102: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

Demo

Page 103: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape
Page 104: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape
Page 105: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

Communicating with the Host Activitypublic interface IDisplayDetail{ bool CanDisplayDetail { get; } void DisplayDetail(Fragment fragmentToDisplay);}

Page 106: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

Communicating with the Host Activityvar displayDetailActivity = Activity as IDisplayDetail; if (displayDetailActivity != null && displayDetailActivity.CanDisplayDetail ) displayDetailActivity.DisplayDetail (new FragmentToAdd ());else StartActivity(new Intent(this.Activity, typeof(AddFragmentActivity)));

Page 107: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

Communicating with the Host Activityvar displayDetailActivity = Activity as IDisplayDetail; if (displayDetailActivity != null && displayDetailActivity.CanDisplayDetail) displayDetailActivity.DisplayDetail (new FragmentToAdd ());else StartActivity(new Intent(this.Activity, typeof(AddFragmentActivity)));

Page 108: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

Communicating with the Host Activityvar displayDetailActivity = Activity as IDisplayDetail; if (displayDetailActivity != null && displayDetailActivity.CanDisplayDetail ) displayDetailActivity.DisplayDetail (new FragmentToAdd ());else StartActivity(new Intent(this.Activity, typeof(AddFragmentActivity)));

Page 109: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

Messaging Alternatives

■ Consider using Events

■ Create an event in your fragment that you can subscribe to in an activity or another fragment

■ When using events, make sure that you unsubscribe properly to avoid any potential memory or subscription issues

When an Interface is Not Enough

Page 110: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

• Fragments are individual modules, but they can work together

• Use an Activity to orchestrate communications between multiple fragments

• Mix-and-Match Fragments when space allows, such as when in landscape mode or on a tablet

Tying It All TogetherWork together in harmony

Page 111: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

bit.ly/1nUpIoUXamarin Fragment Docs

Page 112: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

One Last Thing…

Page 113: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

• Device manufacturers implement Android Differently

• Custom User Interface

• Camera

• Even ListViews!

• Test on all the devices you can get your hands on!

• Check out Xamarin Test Cloud!

Testing. Testing Never Changes

Page 114: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

Questions?

Page 115: Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

Designing Android UIs for the Ever Changing

Device Landscape

Michael Stonis@michaelstonis