SlideShare a Scribd company logo
1 of 115
Download to read offline
Designing Android UIs 
for the Ever Changing 
Device Landscape 
Michael Stonis 
Eight-Bot, Inc. 
@michaelstonis
Unique Android Devices 
20,000 
16,667 
13,333 
10,000 
6,667 
3,333 
0 
2012 2013 2014 
Open Signal, August 2014
Subtitle
Big Opportunity 
Where do we get started?
Big Opportunity 
Where do we get started? 
■ Design Fundamentals
Big Opportunity 
Where do we get started? 
■ Design Fundamentals
Big Opportunity 
Where do we get started? 
■ Design Fundamentals 
■ Layout Management
Big Opportunity 
Where do we get started? 
■ Design Fundamentals 
■ Layout Management
Big Opportunity 
Where do we get started? 
■ Design Fundamentals 
■ Layout Management 
■ Android Fragments
Design Fundamentals
The Big Three 
Screen Size Orientation Pixel Density
The Big Three 
Screen Size Orientation Pixel Density
The Big Three 
Screen Size Orientation Pixel Density
The Big Three 
Screen Size Orientation Pixel Density
Density Independent 
Pixels
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
BAD GOOD
Density Independent Pixel 
160 dpi 
MDPI 
1x 
320 dpi 
XHDPI 
2x 
480 dpi 
XXHDPI 
3x
Density Independent Pixel 
160 dpi 
MDPI 
1x 
320 dpi 
XHDPI 
2x 
480 dpi 
XXHDPI 
3x
Density Independent Pixel 
160 dpi 
MDPI 
1x 
320 dpi 
XHDPI 
2x 
480 dpi 
XXHDPI 
3x
Density 
Independent 
Pixels
Pixels Density 
Independent 
Pixels
Pixels Density 
Independent 
Pixels
Density Independent Pixels 
Nexus 5 
1920 x 1080 px
Density Independent Pixels 
Nexus 5 
1920 x 1080 px 
445 dpi
Density Independent Pixels 
Nexus 5 
1920 x 1080 px 
445 dpi 
1 inch 
445 pixels
Calculating DIPs 
Resolution (px) x 160 
DIP = dpi
Density Independent Pixels 
Nexus 5 
1920 x 1080 px 
445 dpi 
690 x 388 dp 
1920 px X 160 
690 Vertical = 445 dpi 
1080 px X 160 
388 Horizontal = 445 dpi
Density Independent Pixels 
Nexus 5 
1920 x 1080 px 
445 dpi 
690 x 388 dp 
1920 px X 160 
690 Vertical = 445 dpi 
1080 px X 160 
388 Horizontal = 445 dpi
Density Independent Pixels 
Nexus 5 
1920 x 1080 px 
445 dpi 
690 x 388 dp 
1920 px X 160 
690 Vertical = 445 dpi 
1080 px X 160 
388 Horizontal = 445 dpi
Density Independent Pixel 
160 dpi 
MDPI 
1x 
240 dpi 
HDPI 
1.5x 
320 dpi 
XHDPI 
2x 
480 dpi 
XXHDPI 
3x
Density Independent Pixels 
1920 px X 160 
640 Vertical = 480 dpi 
1080 px X 160 
360 Horizontal = 480 dpi 
Nexus 5 
1920 x 1080 px 
445 dpi 
640 x 360 dp
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
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
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
Scale Independent Pixels (SIP) 
Scaling for Fonts 
■ 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
Android Resource 
Qualifiers
Android Resource Qualifiers 
Different Strokes for Different Folks 
• 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
Android Resource Qualifiers 
Qualifier Format 
<resource type>-<qualifier>
Android Resource Qualifiers 
Example 
layout-land 
A layout resource in landscape orientation
Android Resource Qualifiers 
Example 
drawable-large-xhdpi 
A drawable resource on a large screen size with an Extra-high-density screen
Android Resource Qualifiers 
Resource Qualifier Types 
• Region & Language 
■ Mobile Country Code (MCC) 
■ Language and Language Region 
• Device Configuration 
■ Portrait 
■ Landscape 
• Device Size Resolution 
■ Screen Size 
■ Pixel Density 
• Device Features 
■ UI Mode 
■ Hardware Software Keyboard
Android Resource Qualifiers 
bit.ly/1toKVDF
Android Resource Qualifiers 
Different Strokes for Different Folks 
• 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
Density Independent Pixel 
160 dpi 
MDPI 
1x 
240 dpi 
HDPI 
1.5x 
480 dpi 
XXHDPI 
3x 
?
Density Independent Pixel 
160 dpi 
MDPI 
1x 
240 dpi 
HDPI 
1.5x 
480 dpi 
XXHDPI 
3x 
?
Layout Management
Layout Management 
Xamarin Android Designer 
• Full WYSIWYG Editor for Android 
■ Control Management 
■ Document Explorer 
■ XML Editor 
• Layouts are standard Android 
• Supports Editing Multiple Layouts
Layout Management 
Multiple Layouts
Demo
Layout Management 
<?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>
Fragments
Android Fragments 
Application Building Blocks 
• Reusable User-Interface components 
• Conceptually similar to an Activity with 
its own lifecycle and layout 
• Create in XML or programmatically
Android Fragment Creation 
public class FragmentToAdd : Fragment 
{ 
public override void OnCreate (Bundle savedInstanceState) 
{ 
} 
public override View OnCreateView (LayoutInflater inflater, ViewGroup container, Bundle 
savedInstanceState) 
{ 
} 
public override void OnPause () 
{ 
} 
}
Android Fragment Key Lifecycle Methods 
public class FragmentToAdd : Fragment 
{ 
public override void OnCreate (Bundle savedInstanceState) 
{ 
} 
public override View OnCreateView (LayoutInflater inflater, ViewGroup container, Bundle 
savedInstanceState) 
{ 
} 
public override void OnPause () 
{ 
} 
}
12:00 
12:00 
12:00 
Dialog List Preferences
12:00 
12:00 
12:00 
Dialog List Preferences
12:00 
12:00 
12:00 
Dialog List Preferences
12:00 
12:00 
12:00 
Dialog List Preferences
Adding a Fragment
12:00
12:00
12:00
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>
Adding Android Fragments via Code 
using (var transaction = FragmentManager.BeginTransaction()) 
{ 
transaction.Add(Resource.Id.container, new FragmentToAdd()); 
transaction.Commit(); 
}
Adding Android Fragments via Code 
using (var transaction = FragmentManager.BeginTransaction()) 
{ 
transaction.Add(Resource.Id.container, new FragmentToAdd()); 
transaction.Commit(); 
}
Adding Android Fragments via Code 
using (var transaction = FragmentManager.BeginTransaction()) 
{ 
transaction.Add(Resource.Id.container, new FragmentToAdd()); 
transaction.Commit(); 
}
Fragment Manager 
■ Provides Fragment Discovery 
- FindFragmentById and FindFragmentByTag 
■ Manage Fragment Navigation History 
■ Creation of Transactions
Adding Android Fragments via Code 
using (var transaction = FragmentManager.BeginTransaction()) 
{ 
transaction.Add(Resource.Id.container, new FragmentToAdd()); 
transaction.Commit(); 
}
Adding Android Fragments via Code 
using (var transaction = FragmentManager.BeginTransaction()) 
{ 
transaction.Add(Resource.Id.container, new FragmentToAdd()); 
transaction.Commit(); 
}
Adding Android Fragments via Code 
using (var transaction = FragmentManager.BeginTransaction()) 
{ 
transaction.Add(Resource.Id.container, new FragmentToAdd()); 
transaction.Commit(); 
}
Fragment Transactions 
■ Facilitates one-to-many fragment changes 
■ Conceptually similar to database transactions 
■ Can Create, Replace and Remove Fragments
Adding Android Fragments via Code 
using (var transaction = FragmentManager.BeginTransaction()) 
{ 
transaction.Add(Resource.Id.container, new FragmentToAdd()); 
transaction.Commit(); 
}
Adding Android Fragments via Code 
using (var transaction = FragmentManager.BeginTransaction()) 
{ 
transaction.Add(Resource.Id.container, new FragmentToAdd()); 
transaction.Commit(); 
}
Adding Android Fragments via Code 
using (var transaction = FragmentManager.BeginTransaction()) 
{ 
transaction.Add(Resource.Id.container, new FragmentToAdd()); 
transaction.Commit(); 
}
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" />
Adding Android Fragments via Code 
using (var transaction = FragmentManager.BeginTransaction()) 
{ 
transaction.Add(Resource.Id.container, new FragmentToAdd()); 
transaction.Commit(); 
}
12:00
12:00
12:00
12:00
12:00
12:00
Replacing Android Fragments 
using (var transaction = FragmentManager.BeginTransaction()) 
{ 
transaction.SetCustomAnimations( 
Android.Resource.Animator.FadeIn, 
Android.Resource.Animator.FadeOut); 
transaction.Replace(Resource.Id.container, new FragmentToAdd()); 
transaction.Commit(); 
}
Communicating with 
Fragments
Build for Modularity 
Think like Building Blocks 
• 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
Providing Data to a Fragment 
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);
Guaranteeing Fragment Receives Data 
public 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; 
}
Guaranteeing Fragment Receives Data 
public 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; 
}
Messaging with the Host Activity 
Passing notes in class is okay 
• 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
Demo
Communicating with the Host Activity 
public interface IDisplayDetail 
{ 
bool CanDisplayDetail { get; } 
void DisplayDetail(Fragment fragmentToDisplay); 
}
Communicating with the Host Activity 
var displayDetailActivity = Activity as IDisplayDetail; 
if (displayDetailActivity != null && displayDetailActivity.CanDisplayDetail ) 
displayDetailActivity.DisplayDetail (new FragmentToAdd ()); 
else 
StartActivity(new Intent(this.Activity, typeof(AddFragmentActivity)));
Communicating with the Host Activity 
var displayDetailActivity = Activity as IDisplayDetail; 
if (displayDetailActivity != null && displayDetailActivity.CanDisplayDetail) 
displayDetailActivity.DisplayDetail (new FragmentToAdd ()); 
else 
StartActivity(new Intent(this.Activity, typeof(AddFragmentActivity)));
Communicating with the Host Activity 
var displayDetailActivity = Activity as IDisplayDetail; 
if (displayDetailActivity != null && displayDetailActivity.CanDisplayDetail ) 
displayDetailActivity.DisplayDetail (new FragmentToAdd ()); 
else 
StartActivity(new Intent(this.Activity, typeof(AddFragmentActivity)));
Messaging Alternatives 
When an Interface is Not Enough 
■ 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
Tying It All Together 
Work together in harmony 
• 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
Xamarin Fragment Docs 
bit.ly/1nUpIoU
One Last Thing…
Testing. Testing Never Changes 
• 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!
Questions?
Designing Android UIs 
for the Ever Changing 
Device Landscape 
Michael Stonis 
@michaelstonis

More Related Content

Similar to Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape

Beating Android Fragmentation, Brett Duncavage
Beating Android Fragmentation, Brett DuncavageBeating Android Fragmentation, Brett Duncavage
Beating Android Fragmentation, Brett DuncavageXamarin
 
Introduction to mobile programming with Androids.
Introduction to mobile programming with Androids. Introduction to mobile programming with Androids.
Introduction to mobile programming with Androids. Maksim Golivkin
 
Creating apps that work on all screen sizes
Creating apps that work on all screen sizesCreating apps that work on all screen sizes
Creating apps that work on all screen sizesRavi Vyas
 
Supporting multiple screens on android
Supporting multiple screens on androidSupporting multiple screens on android
Supporting multiple screens on androidLi SUN
 
Measuring the Mobile Experience: The Analytics of Handheld UX
Measuring the Mobile Experience: The Analytics of Handheld UXMeasuring the Mobile Experience: The Analytics of Handheld UX
Measuring the Mobile Experience: The Analytics of Handheld UXKen Tabor
 
How to deal with Fragmentation on Android
How to deal with Fragmentation on AndroidHow to deal with Fragmentation on Android
How to deal with Fragmentation on AndroidSittiphol Phanvilai
 
3 Approaches to Mobile - An A to Z Primer.
3 Approaches to Mobile - An A to Z Primer.3 Approaches to Mobile - An A to Z Primer.
3 Approaches to Mobile - An A to Z Primer.agup2009
 
High DPI for desktop applications
High DPI for desktop applicationsHigh DPI for desktop applications
High DPI for desktop applicationsKirill Grouchnikov
 
viWave Study Group - Introduction to Google Android Development - Chapter 23 ...
viWave Study Group - Introduction to Google Android Development - Chapter 23 ...viWave Study Group - Introduction to Google Android Development - Chapter 23 ...
viWave Study Group - Introduction to Google Android Development - Chapter 23 ...Ted Chien
 
Advanced Design Methods 1, Day 1
Advanced Design Methods 1, Day 1Advanced Design Methods 1, Day 1
Advanced Design Methods 1, Day 1Aaron Gustafson
 
Building the Ultimate Device Matrix
Building the Ultimate Device MatrixBuilding the Ultimate Device Matrix
Building the Ultimate Device MatrixCarly Vanderwert
 
Responsive & Adaptive Design @mLearnCon15 Nick Floro
Responsive & Adaptive Design @mLearnCon15 Nick FloroResponsive & Adaptive Design @mLearnCon15 Nick Floro
Responsive & Adaptive Design @mLearnCon15 Nick FloroNick Floro
 
Ts android supporting multiple screen
Ts   android supporting multiple screenTs   android supporting multiple screen
Ts android supporting multiple screenConfiz
 
UX and UI Designing for all android screen
UX and UI Designing for all android screenUX and UI Designing for all android screen
UX and UI Designing for all android screenArnold Saputra
 
Using the Presentation API and external screens on Android
Using the Presentation API and external screens on AndroidUsing the Presentation API and external screens on Android
Using the Presentation API and external screens on AndroidXavier Hallade
 
Android v 1.1
Android v 1.1Android v 1.1
Android v 1.1Ravi Vyas
 

Similar to Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Landscape (20)

UI and UX for Mobile Developers
UI and UX for Mobile DevelopersUI and UX for Mobile Developers
UI and UX for Mobile Developers
 
Beating Android Fragmentation, Brett Duncavage
Beating Android Fragmentation, Brett DuncavageBeating Android Fragmentation, Brett Duncavage
Beating Android Fragmentation, Brett Duncavage
 
Introduction to mobile programming with Androids.
Introduction to mobile programming with Androids. Introduction to mobile programming with Androids.
Introduction to mobile programming with Androids.
 
Creating apps that work on all screen sizes
Creating apps that work on all screen sizesCreating apps that work on all screen sizes
Creating apps that work on all screen sizes
 
divide and qonquer
divide and qonquerdivide and qonquer
divide and qonquer
 
Supporting multiple screens on android
Supporting multiple screens on androidSupporting multiple screens on android
Supporting multiple screens on android
 
Measuring the Mobile Experience: The Analytics of Handheld UX
Measuring the Mobile Experience: The Analytics of Handheld UXMeasuring the Mobile Experience: The Analytics of Handheld UX
Measuring the Mobile Experience: The Analytics of Handheld UX
 
How to deal with Fragmentation on Android
How to deal with Fragmentation on AndroidHow to deal with Fragmentation on Android
How to deal with Fragmentation on Android
 
3 Approaches to Mobile - An A to Z Primer.
3 Approaches to Mobile - An A to Z Primer.3 Approaches to Mobile - An A to Z Primer.
3 Approaches to Mobile - An A to Z Primer.
 
High DPI for desktop applications
High DPI for desktop applicationsHigh DPI for desktop applications
High DPI for desktop applications
 
viWave Study Group - Introduction to Google Android Development - Chapter 23 ...
viWave Study Group - Introduction to Google Android Development - Chapter 23 ...viWave Study Group - Introduction to Google Android Development - Chapter 23 ...
viWave Study Group - Introduction to Google Android Development - Chapter 23 ...
 
Advanced Design Methods 1, Day 1
Advanced Design Methods 1, Day 1Advanced Design Methods 1, Day 1
Advanced Design Methods 1, Day 1
 
Building the Ultimate Device Matrix
Building the Ultimate Device MatrixBuilding the Ultimate Device Matrix
Building the Ultimate Device Matrix
 
Responsive & Adaptive Design @mLearnCon15 Nick Floro
Responsive & Adaptive Design @mLearnCon15 Nick FloroResponsive & Adaptive Design @mLearnCon15 Nick Floro
Responsive & Adaptive Design @mLearnCon15 Nick Floro
 
Ts android supporting multiple screen
Ts   android supporting multiple screenTs   android supporting multiple screen
Ts android supporting multiple screen
 
UX and UI Designing for all android screen
UX and UI Designing for all android screenUX and UI Designing for all android screen
UX and UI Designing for all android screen
 
WaveEngine Dotnet 2018
WaveEngine Dotnet 2018WaveEngine Dotnet 2018
WaveEngine Dotnet 2018
 
Using the Presentation API and external screens on Android
Using the Presentation API and external screens on AndroidUsing the Presentation API and external screens on Android
Using the Presentation API and external screens on Android
 
From Vision to Visualization with ProtoTech Solutions
From Vision to Visualization with ProtoTech SolutionsFrom Vision to Visualization with ProtoTech Solutions
From Vision to Visualization with ProtoTech Solutions
 
Android v 1.1
Android v 1.1Android v 1.1
Android v 1.1
 

Recently uploaded

Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech studentsHimanshiGarg82
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfryanfarris8
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdfPearlKirahMaeRagusta1
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfVishalKumarJha10
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...kalichargn70th171
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnAmarnathKambale
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfproinshot.com
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 

Recently uploaded (20)

Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 

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

  • 1. Designing Android UIs for the Ever Changing Device Landscape Michael Stonis Eight-Bot, Inc. @michaelstonis
  • 2.
  • 3. Unique Android Devices 20,000 16,667 13,333 10,000 6,667 3,333 0 2012 2013 2014 Open Signal, August 2014
  • 5. Big Opportunity Where do we get started?
  • 6. Big Opportunity Where do we get started? ■ Design Fundamentals
  • 7. Big Opportunity Where do we get started? ■ Design Fundamentals
  • 8. Big Opportunity Where do we get started? ■ Design Fundamentals ■ Layout Management
  • 9. Big Opportunity Where do we get started? ■ Design Fundamentals ■ Layout Management
  • 10. Big Opportunity Where do we get started? ■ Design Fundamentals ■ Layout Management ■ Android Fragments
  • 12. The Big Three Screen Size Orientation Pixel Density
  • 13. The Big Three Screen Size Orientation Pixel Density
  • 14. The Big Three Screen Size Orientation Pixel Density
  • 15. The Big Three Screen Size Orientation Pixel Density
  • 17.
  • 18.
  • 19.
  • 20.
  • 21. 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
  • 23. Density Independent Pixel 160 dpi MDPI 1x 320 dpi XHDPI 2x 480 dpi XXHDPI 3x
  • 24. Density Independent Pixel 160 dpi MDPI 1x 320 dpi XHDPI 2x 480 dpi XXHDPI 3x
  • 25. Density Independent Pixel 160 dpi MDPI 1x 320 dpi XHDPI 2x 480 dpi XXHDPI 3x
  • 29. Density Independent Pixels Nexus 5 1920 x 1080 px
  • 30. Density Independent Pixels Nexus 5 1920 x 1080 px 445 dpi
  • 31. Density Independent Pixels Nexus 5 1920 x 1080 px 445 dpi 1 inch 445 pixels
  • 32. Calculating DIPs Resolution (px) x 160 DIP = dpi
  • 33. Density Independent Pixels Nexus 5 1920 x 1080 px 445 dpi 690 x 388 dp 1920 px X 160 690 Vertical = 445 dpi 1080 px X 160 388 Horizontal = 445 dpi
  • 34. Density Independent Pixels Nexus 5 1920 x 1080 px 445 dpi 690 x 388 dp 1920 px X 160 690 Vertical = 445 dpi 1080 px X 160 388 Horizontal = 445 dpi
  • 35. Density Independent Pixels Nexus 5 1920 x 1080 px 445 dpi 690 x 388 dp 1920 px X 160 690 Vertical = 445 dpi 1080 px X 160 388 Horizontal = 445 dpi
  • 36. Density Independent Pixel 160 dpi MDPI 1x 240 dpi HDPI 1.5x 320 dpi XHDPI 2x 480 dpi XXHDPI 3x
  • 37. Density Independent Pixels 1920 px X 160 640 Vertical = 480 dpi 1080 px X 160 360 Horizontal = 480 dpi Nexus 5 1920 x 1080 px 445 dpi 640 x 360 dp
  • 38. 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
  • 39. 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
  • 40. 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
  • 41.
  • 42.
  • 43.
  • 44. Scale Independent Pixels (SIP) Scaling for Fonts ■ 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
  • 46. Android Resource Qualifiers Different Strokes for Different Folks • 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
  • 47. Android Resource Qualifiers Qualifier Format <resource type>-<qualifier>
  • 48. Android Resource Qualifiers Example layout-land A layout resource in landscape orientation
  • 49. Android Resource Qualifiers Example drawable-large-xhdpi A drawable resource on a large screen size with an Extra-high-density screen
  • 50. Android Resource Qualifiers Resource Qualifier Types • Region & Language ■ Mobile Country Code (MCC) ■ Language and Language Region • Device Configuration ■ Portrait ■ Landscape • Device Size Resolution ■ Screen Size ■ Pixel Density • Device Features ■ UI Mode ■ Hardware Software Keyboard
  • 51. Android Resource Qualifiers bit.ly/1toKVDF
  • 52. Android Resource Qualifiers Different Strokes for Different Folks • 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
  • 53. Density Independent Pixel 160 dpi MDPI 1x 240 dpi HDPI 1.5x 480 dpi XXHDPI 3x ?
  • 54. Density Independent Pixel 160 dpi MDPI 1x 240 dpi HDPI 1.5x 480 dpi XXHDPI 3x ?
  • 56. Layout Management Xamarin Android Designer • Full WYSIWYG Editor for Android ■ Control Management ■ Document Explorer ■ XML Editor • Layouts are standard Android • Supports Editing Multiple Layouts
  • 58. Demo
  • 59. Layout Management <?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>
  • 61.
  • 62.
  • 63.
  • 64. Android Fragments Application Building Blocks • Reusable User-Interface components • Conceptually similar to an Activity with its own lifecycle and layout • Create in XML or programmatically
  • 65. Android Fragment Creation public class FragmentToAdd : Fragment { public override void OnCreate (Bundle savedInstanceState) { } public override View OnCreateView (LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { } public override void OnPause () { } }
  • 66. Android Fragment Key Lifecycle Methods public class FragmentToAdd : Fragment { public override void OnCreate (Bundle savedInstanceState) { } public override View OnCreateView (LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { } public override void OnPause () { } }
  • 67. 12:00 12:00 12:00 Dialog List Preferences
  • 68. 12:00 12:00 12:00 Dialog List Preferences
  • 69. 12:00 12:00 12:00 Dialog List Preferences
  • 70. 12:00 12:00 12:00 Dialog List Preferences
  • 72. 12:00
  • 73. 12:00
  • 74. 12:00
  • 75. 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>
  • 76. Adding Android Fragments via Code using (var transaction = FragmentManager.BeginTransaction()) { transaction.Add(Resource.Id.container, new FragmentToAdd()); transaction.Commit(); }
  • 77. Adding Android Fragments via Code using (var transaction = FragmentManager.BeginTransaction()) { transaction.Add(Resource.Id.container, new FragmentToAdd()); transaction.Commit(); }
  • 78. Adding Android Fragments via Code using (var transaction = FragmentManager.BeginTransaction()) { transaction.Add(Resource.Id.container, new FragmentToAdd()); transaction.Commit(); }
  • 79. Fragment Manager ■ Provides Fragment Discovery - FindFragmentById and FindFragmentByTag ■ Manage Fragment Navigation History ■ Creation of Transactions
  • 80. Adding Android Fragments via Code using (var transaction = FragmentManager.BeginTransaction()) { transaction.Add(Resource.Id.container, new FragmentToAdd()); transaction.Commit(); }
  • 81. Adding Android Fragments via Code using (var transaction = FragmentManager.BeginTransaction()) { transaction.Add(Resource.Id.container, new FragmentToAdd()); transaction.Commit(); }
  • 82. Adding Android Fragments via Code using (var transaction = FragmentManager.BeginTransaction()) { transaction.Add(Resource.Id.container, new FragmentToAdd()); transaction.Commit(); }
  • 83. Fragment Transactions ■ Facilitates one-to-many fragment changes ■ Conceptually similar to database transactions ■ Can Create, Replace and Remove Fragments
  • 84. Adding Android Fragments via Code using (var transaction = FragmentManager.BeginTransaction()) { transaction.Add(Resource.Id.container, new FragmentToAdd()); transaction.Commit(); }
  • 85. Adding Android Fragments via Code using (var transaction = FragmentManager.BeginTransaction()) { transaction.Add(Resource.Id.container, new FragmentToAdd()); transaction.Commit(); }
  • 86. Adding Android Fragments via Code using (var transaction = FragmentManager.BeginTransaction()) { transaction.Add(Resource.Id.container, new FragmentToAdd()); transaction.Commit(); }
  • 87. 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" />
  • 88. Adding Android Fragments via Code using (var transaction = FragmentManager.BeginTransaction()) { transaction.Add(Resource.Id.container, new FragmentToAdd()); transaction.Commit(); }
  • 89. 12:00
  • 90. 12:00
  • 91. 12:00
  • 92. 12:00
  • 93. 12:00
  • 94. 12:00
  • 95. Replacing Android Fragments using (var transaction = FragmentManager.BeginTransaction()) { transaction.SetCustomAnimations( Android.Resource.Animator.FadeIn, Android.Resource.Animator.FadeOut); transaction.Replace(Resource.Id.container, new FragmentToAdd()); transaction.Commit(); }
  • 97. Build for Modularity Think like Building Blocks • 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
  • 98. Providing Data to a Fragment 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);
  • 99. Guaranteeing Fragment Receives Data public 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; }
  • 100. Guaranteeing Fragment Receives Data public 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; }
  • 101. Messaging with the Host Activity Passing notes in class is okay • 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
  • 102. Demo
  • 103.
  • 104.
  • 105. Communicating with the Host Activity public interface IDisplayDetail { bool CanDisplayDetail { get; } void DisplayDetail(Fragment fragmentToDisplay); }
  • 106. Communicating with the Host Activity var displayDetailActivity = Activity as IDisplayDetail; if (displayDetailActivity != null && displayDetailActivity.CanDisplayDetail ) displayDetailActivity.DisplayDetail (new FragmentToAdd ()); else StartActivity(new Intent(this.Activity, typeof(AddFragmentActivity)));
  • 107. Communicating with the Host Activity var displayDetailActivity = Activity as IDisplayDetail; if (displayDetailActivity != null && displayDetailActivity.CanDisplayDetail) displayDetailActivity.DisplayDetail (new FragmentToAdd ()); else StartActivity(new Intent(this.Activity, typeof(AddFragmentActivity)));
  • 108. Communicating with the Host Activity var displayDetailActivity = Activity as IDisplayDetail; if (displayDetailActivity != null && displayDetailActivity.CanDisplayDetail ) displayDetailActivity.DisplayDetail (new FragmentToAdd ()); else StartActivity(new Intent(this.Activity, typeof(AddFragmentActivity)));
  • 109. Messaging Alternatives When an Interface is Not Enough ■ 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
  • 110. Tying It All Together Work together in harmony • 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
  • 111. Xamarin Fragment Docs bit.ly/1nUpIoU
  • 113. Testing. Testing Never Changes • 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!
  • 115. Designing Android UIs for the Ever Changing Device Landscape Michael Stonis @michaelstonis