SlideShare ist ein Scribd-Unternehmen logo
1 von 27
Cross Platform Image
Resources Management
in
Xamarin.Forms
- Udara Alwis -
CODENAME: [ÇøŋfuzëÐ SøurcëÇødë]
I am Udara Alwis
• Xamarin Developer / Enthusiast
• Mad Love for Mobile Development / UX
• Microsoft Dot Net FTW!
• 23 Years of Awesomess… 
• Nature, Adventures, Running, Skateboarding, Cycling and Socializing
• Occasional YouTube-er!
linkedin.com/in/UdaraAlwis
Yay! Xamarin Forms!
• Truly Cross platform
• Native Performance
• Native Looks and Feel
• Share almost up to 100% of codebase
Take a moment… Resources?
• Resources in Mobile App Development
• For Decorating/Enhancing/Improving a Mobile App
• Specially Image Resources
• IT IS CRUICIAL!
• Specially Cross Platform Mobile Development!
• How about Xamarin Forms?
Xamarin Forms? Image Resources?
• Two ways,
1. Local Images
2. Embedded Images (Resources)
1. Xamarin Forms Local Images
• Image Files to be added to each application project
• Reference from Xamarin.Forms shared code level
• Same File Name for every platform
• Fully Native features. But Properties Should be
configured locally
(Build Actions, Sub-Directories, Resolution Support, etc…)
• Valid File naming for each platform
2. Xamarin Forms Embedded Images
• Image File are Embedded in the PCL Assembly
as Resources
• Build Action: EmbeddedResource
• Centralized…
• No control over Screen Resolution / Device Type
• Handle everything through code
Blah blah… in reality, it sucks!
• Duplicate Effort? Or Triplicate?
• Hard to make changes, update and monitor
• Resources, only going to increase.. Imagine 50? 100?
• Naming conventions?
• Manual Management of everything
• Multi-Resolution / Multi-Device Support, NIGHTMARE!
• As Embedded Images? Give me a break! Lol
So what is the Solution?
• Think about it…
• We need a solution that,
• lets you store your images in one place (ex: PCL Project level)
• provides multi-screen resolution/ device type support
• And doesn’t suck!
• Our Struggle? Yes it is real!
Behold, Forms9Patch Library
“ Simplify image management and text formatting
in your PCL Xamarin.Forms mobile apps…”
• Provides Centralized Image Resources management
• With complete multi-resolution/Device support
• Exclusively for Xamarin.Forms
• For iOS and Android. But unfortunately not yet for Windows Phone
Forms9Patch Library…
• Manage all your Image Resources right from your PCL project
• Generate and configure your Image Resources once.
• Finds the best fit image among the provided images based on Screen
Resolution/ Device type
Xamarin Forms Image Mechanics?
• Xamarin.Forms.ImageSource Instance
• Instance that loads (from File or Web) and holds the Image Source object in
memory
• Xamarin.Forms.Image Control/View
• UI Control or the View that displays and populates the ImageSource on to the
User Interface
Likewise Forms9Patch?
• Forms9Patch.ImageSource instance
- Extends Xamarin.Forms.ImageSource
• Forms9Patch.Image Control/View
- Extends Xamarin.Forms.Image
• Interchangeable in-between
Forms9Patch.ImageSource instance
- Automatically loads the best fit image among the provided images
(EmbeddedResource) based on screen-resolution/device
- No need of explicit image extension
- Forms9Patch.ImageSource.FromMultiResource() static method
- Supports same file formats as Xamarin.Forms.ImageSource
Forms9Patch.Image Control/View
- Scalable image view
- Ability to Tile an image within its parent
Stretch-ability of an Image
• Native development situation?
• iOS's provides resizableImageWithCapInsets
• make an UIImage a scalable image
• CapInset argument is used to specify the regions (distance inset from
the edges) which will not scale
Stretch-ability of an Image
• Android provides NinePatchDrawable to allow apps to
• display Nine-patch images as scalable drawing elements.
• used to mark the regions that are allowed scale
Stretch-ability of an Image
• Both are great!
• Android Nine-patch image format allows for un-scalable regions to be
anywhere in the image (not just at the edges).
• Scaled regions are marked within the image file
• So scaling can be customized to each file
• iOS resizableImageWithCapInsets define the scaling regions at
runtime - which provides some flexibility and convenience.
Stretch-ability of an Image in Forms9Patch
• Seeing the advantages to both approaches,
• Forms9Patch.Image allows for both.
• If NinePatch image is provided -> Use the Android approach
• If CapInsets property is provided -> Use the iOS approach
• Duh! You can’t use both!
• CapInsets will override NinePath image regions
Stretch-ability of an Image in Forms9Patch
• Yes thanks to Forms9Patch now you could
• Use Android’s Nine-Patch image stretch-ability in iOS
• And iOS’s resizableImageWithCapInsets in Android
• With Nine-Patch image or CapInsets property
NinePatch Image vs CapInsets in Forms9Patch
Forms9Patch Naming Convention Schema
• Unique naming convention
• Identification of multi-device / multi-resolution image files
• Similar to iOS approach has ~3x better performance
• project_assembly_name.image_path.base_image_name
[resolution_modifier][device_modifier].filename_extension
Forms9Patch Naming Convention Schema
Demo– Let’s try it out
Forms9Patch Extra Goodies…
• Forms9Patch.Label
- Custom Fonts
- HTML Formatted Text
• ImageButton
- State Support, Gestures
• Forms9Patch Layouts
- AbsoluteLayout, Frame, Grid, RelativeLayout and StackLayout
• Etc…. So much more…
• More about Forms9Patch : http://forms9patch.com/
Conclusion
• Image Resource Management in Cross Platform Mobile
Development is crucial
• Xamarin Forms default Image Management is not
sufficient enough
• Forms9Patch Library provides Provides Centralized Image Resources
management
• With complete multi-resolution/Device support
Thank You!
For Weekly Xamarin Articles check out my blog,
https://theconfuzedsourcecode.wordpress.com
-Udara Alwis
CODENAME: [ÇøŋfuzëÐ SøurcëÇødë]

Weitere ähnliche Inhalte

KĂźrzlich hochgeladen

Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
chiefasafspells
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
masabamasaba
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
masabamasaba
 
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 

KĂźrzlich hochgeladen (20)

Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the Situation
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
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
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 
WSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security Program
 
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 

Empfohlen

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 

Empfohlen (20)

Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 

Cross Platform Image Resources Management in Xamarin Forms

  • 1. Cross Platform Image Resources Management in Xamarin.Forms - Udara Alwis - CODENAME: [ÇøŋfuzÍÐ SøurcëÇødĂŤ]
  • 2. I am Udara Alwis • Xamarin Developer / Enthusiast • Mad Love for Mobile Development / UX • Microsoft Dot Net FTW! • 23 Years of Awesomess…  • Nature, Adventures, Running, Skateboarding, Cycling and Socializing • Occasional YouTube-er! linkedin.com/in/UdaraAlwis
  • 3. Yay! Xamarin Forms! • Truly Cross platform • Native Performance • Native Looks and Feel • Share almost up to 100% of codebase
  • 4. Take a moment… Resources? • Resources in Mobile App Development • For Decorating/Enhancing/Improving a Mobile App • Specially Image Resources • IT IS CRUICIAL! • Specially Cross Platform Mobile Development! • How about Xamarin Forms?
  • 5. Xamarin Forms? Image Resources? • Two ways, 1. Local Images 2. Embedded Images (Resources)
  • 6. 1. Xamarin Forms Local Images • Image Files to be added to each application project • Reference from Xamarin.Forms shared code level • Same File Name for every platform • Fully Native features. But Properties Should be configured locally (Build Actions, Sub-Directories, Resolution Support, etc…) • Valid File naming for each platform
  • 7. 2. Xamarin Forms Embedded Images • Image File are Embedded in the PCL Assembly as Resources • Build Action: EmbeddedResource • Centralized… • No control over Screen Resolution / Device Type • Handle everything through code
  • 8. Blah blah… in reality, it sucks! • Duplicate Effort? Or Triplicate? • Hard to make changes, update and monitor • Resources, only going to increase.. Imagine 50? 100? • Naming conventions? • Manual Management of everything • Multi-Resolution / Multi-Device Support, NIGHTMARE! • As Embedded Images? Give me a break! Lol
  • 9. So what is the Solution? • Think about it… • We need a solution that, • lets you store your images in one place (ex: PCL Project level) • provides multi-screen resolution/ device type support • And doesn’t suck! • Our Struggle? Yes it is real!
  • 10. Behold, Forms9Patch Library “ Simplify image management and text formatting in your PCL Xamarin.Forms mobile apps…” • Provides Centralized Image Resources management • With complete multi-resolution/Device support • Exclusively for Xamarin.Forms • For iOS and Android. But unfortunately not yet for Windows Phone
  • 11. Forms9Patch Library… • Manage all your Image Resources right from your PCL project • Generate and configure your Image Resources once. • Finds the best fit image among the provided images based on Screen Resolution/ Device type
  • 12. Xamarin Forms Image Mechanics? • Xamarin.Forms.ImageSource Instance • Instance that loads (from File or Web) and holds the Image Source object in memory • Xamarin.Forms.Image Control/View • UI Control or the View that displays and populates the ImageSource on to the User Interface
  • 13. Likewise Forms9Patch? • Forms9Patch.ImageSource instance - Extends Xamarin.Forms.ImageSource • Forms9Patch.Image Control/View - Extends Xamarin.Forms.Image • Interchangeable in-between
  • 14. Forms9Patch.ImageSource instance - Automatically loads the best fit image among the provided images (EmbeddedResource) based on screen-resolution/device - No need of explicit image extension - Forms9Patch.ImageSource.FromMultiResource() static method - Supports same file formats as Xamarin.Forms.ImageSource
  • 15. Forms9Patch.Image Control/View - Scalable image view - Ability to Tile an image within its parent
  • 16. Stretch-ability of an Image • Native development situation? • iOS's provides resizableImageWithCapInsets • make an UIImage a scalable image • CapInset argument is used to specify the regions (distance inset from the edges) which will not scale
  • 17. Stretch-ability of an Image • Android provides NinePatchDrawable to allow apps to • display Nine-patch images as scalable drawing elements. • used to mark the regions that are allowed scale
  • 18. Stretch-ability of an Image • Both are great! • Android Nine-patch image format allows for un-scalable regions to be anywhere in the image (not just at the edges). • Scaled regions are marked within the image file • So scaling can be customized to each file • iOS resizableImageWithCapInsets define the scaling regions at runtime - which provides some flexibility and convenience.
  • 19. Stretch-ability of an Image in Forms9Patch • Seeing the advantages to both approaches, • Forms9Patch.Image allows for both. • If NinePatch image is provided -> Use the Android approach • If CapInsets property is provided -> Use the iOS approach • Duh! You can’t use both! • CapInsets will override NinePath image regions
  • 20. Stretch-ability of an Image in Forms9Patch • Yes thanks to Forms9Patch now you could • Use Android’s Nine-Patch image stretch-ability in iOS • And iOS’s resizableImageWithCapInsets in Android • With Nine-Patch image or CapInsets property
  • 21. NinePatch Image vs CapInsets in Forms9Patch
  • 22. Forms9Patch Naming Convention Schema • Unique naming convention • Identification of multi-device / multi-resolution image files • Similar to iOS approach has ~3x better performance • project_assembly_name.image_path.base_image_name [resolution_modifier][device_modifier].filename_extension
  • 25. Forms9Patch Extra Goodies… • Forms9Patch.Label - Custom Fonts - HTML Formatted Text • ImageButton - State Support, Gestures • Forms9Patch Layouts - AbsoluteLayout, Frame, Grid, RelativeLayout and StackLayout • Etc…. So much more… • More about Forms9Patch : http://forms9patch.com/
  • 26. Conclusion • Image Resource Management in Cross Platform Mobile Development is crucial • Xamarin Forms default Image Management is not sufficient enough • Forms9Patch Library provides Provides Centralized Image Resources management • With complete multi-resolution/Device support
  • 27. Thank You! For Weekly Xamarin Articles check out my blog, https://theconfuzedsourcecode.wordpress.com -Udara Alwis CODENAME: [ÇøŋfuzÍÐ SøurcëÇødĂŤ]

Hinweis der Redaktion

  1. Hey guys! How are you today? Come on cheer up! It’s the end of the day! Lol Before I begin, quick raise of hands, who’s done any Xamarin Forms development Native Mobile Dev? Android iOS Windows Phone? Perfect! I think we are in perfect grounds to proceed with my presentation
  2. My name is Udara Alwis. I’m a Xamarin Developer here in Singapore, and guilty as charged I’m a crazy Xamarin enthusiast. I’ve got some mad love for Mobile Development and Mobile User Experience Engineering Of course I’m a Microsoft fan boy. There goes by saying I’m still 24 years old. When I’m not coding, I go on adventures, running, cycling, skateboarding.. All that fun stuff!
  3. So yay! Xamarin Forms.. The true cross platform approach of Xamarin Let’s you development mobile apps using dot net, with fully native performance and look and feel. And it allows you to share upto almost 100% of codebase across three platforms. Xamarin Forms is awesome!
  4. Now let’s take a moment, and talk about Resources in Mobile Application Development. We usually use Resources for decorating, enhancing and improving the User Experience in our Mobile Apps. Specifically Image Resources plays a huge role in it. So managing Image Resources in our mobile app development is very crucial, and it’s even more crucial when it comes to Cross Platform Mobile Development. Because you need to be aware… Now how about beloved Xamarin Forms?
  5. Basically Xamarin Forms provides two approaches To Manage our Image Resources First approach, is by having our Images as Local Images in the Native Project level. Secondly, having our Images as Embedded Resources in the PCL project level. Alright let’s get into details of them…
  6. Now the first approach, allows us to have our images in the Native Project level in all three platforms as you can see in the picture And we could reference those Images in the Share Code level. But we need to have the same file name for each platform. True, this approach provides you with fully native properties and behaviors for our Images And we need to configure those Image Resources manually for each platform. Such as… Also it is cruicial whenever you name the Image, to make sure that naming convention supports all three platforms, because as we know…
  7. Now speaking of the second approach, Xamarin Forms lets us add our Image Files as Embedded Resources in the PCL project This approach provides more of a centralized resource management But still the biggest bummer is that, it doesn’t give any control over Screen Resolution and Device Type handling If you want to do that, you have to handle every single detail in the code level itself, which is a very complex.
  8. Two Components for dealing with Images
  9. Now let’s take a moment and talk about Stretch-Ability of an image. This is about how our images are resized during the runtime with in the parent view or on the device screen based on the screen resolution or the type of device This is a very important aspect in Image Resources handling, because we need to make sure These images are stretched accordingly at runtime without disrupting the User Experience of the app. How this is handled in native development? iOS? iOS provides resizableImageWIthCapInsets functionality which allows us to stretch the UIImage control The CapInsets property that we are using here allows us to define the regions of the image which we do not want to stretch and allows the rest of the image to be stretched through out the Parent’s bounds. If you are not familiar take a look at the image at the bottom where we define the top,let,right,bottom inset regions which shouldn’t get stretched but the rest of the image get’s stretched.
  10. Now how about Android, it provides us the NinePatchImage Drawables approach Where it allows us to mark the specific regions that we want the image to be stretched using the nine patch image tool that comes with Android sdk tools. So at the runtime only those regions will get stretched in parent view. If you are not familiar with Android development, you can take a look at the image, how we have marked the regions that we need to scale during runtime
  11. Now both these native approaches are great, although they are totally different. Android provides us the Nine Patch image format allowing us to define the regions of the image that we want to scale. Which could be anywhere on the image. So hence we are marking these stretchable regions in the image file, we could customize it for each file based on resolution or the device type that we support with our resources Which is very flexible and powerful given the vast sea of device types we have out there for Android On iOS resizableImageWithCapInsets defines the regions that we do not want to scale during runtime, which also gives somewhat flexibility. But in this case we don’t have much to worry because Apple device have pretty much pre-defined screen sizes and device types. So both these aspects have their own advantages considering their native environments
  12. Ok so Forms9Patch allows us to manage our Image Resources in PCL project and brings a lot more great features. But how are we to address those Image Resources and reference them in our code. Forms9Patch introduces a unique naming convention for the image resources, by allowing them to identify themselves for the support of multi-resolution and device type support which is much similar to iOS resource naming convention hence it has better performance than Android naming convention.