SlideShare uma empresa Scribd logo
1 de 34
Baixar para ler offline
Android
Fragment-Awesome
     Matthew Gaunt
Who is this guy?

• Master in Computer Science in Bristol
• Senior Android Dev @ Mubaloo
• Cross Platform Dev @ Future Platforms
What Fragmentation?
What’s coming up
• Design - I can haz pretty
 • Dips
 • Buckets?
 • What buckets?
 • The story of buckets
• Tips + Examples
Dips

Density Independent Pixels
Abstract the screen size (think rounded
corner rectangle)
Never assume dip > pixels
Buckets?




ldpi   mdpi   hdpi   xhdpi
What Buckets?
Screen density (ldpi, mdpi, hdpi, xhdpi)

Orientation (port, land)

Android Version (v4, v11)

Screen size (small, normal, large, xlarge)
Eeks lots of Images
How to use Buckets

• Images - [ldpi, mdpi, hdpi, xhdpi] [small, normal, large, xlarge]


• Layout -[land, port]


• Themes / Styles -          [v4, v11]


• Dimensions -       [small, normal, large, xlarge]
The History...
The History...


<port>
 land

  1.5
The History...

           ldpi
<port>     mdpi
 land      hdpi
  1.5       1.6
The History...
                   small
           ldpi   normal
<port>     mdpi    large
 land      hdpi   xlarge
  1.5       1.6    3.0 (ish)
The History...
                   small
           ldpi   normal        ldpi
                                mdpi
<port>     mdpi    large        hdpi
 land      hdpi   xlarge       xhdpi
  1.5       1.6    3.0 (ish)    4.0
Recap

• Lots of buckets
• Lots of resources to apply the buckets to
• How it relates to other platforms like iOS
Random.
Phones / Tablets?
                    ldpi   mdpi  hdpi xhdpi  total
Small              1.7%           2.4%       4.1%
Normal             0.7%    18.5% 66.3% 2.5% 88.0%
Large              0.2%     2.8%             3.0%
XLarge                      4.9%             4.9%

       ldpi
      mdpi                               mdpi
       hdpi                            ? hdpi ?
      xhdpi                           ? xhdpi ?

 Phones                            Tablets
  normal / small                    large / xlarge
Hitting Both?
drawable              For all buckets
drawable-ldpi
drawable-mdpi
                           Base
drawable-hdpi
drawable-xhdpi
drawable-large-?
                        Additional
drawable-xlarge-?
Tips to Reduce Work

            1
 Use values everywhere
   (dimens, ints, etc.)
Tips to Reduce Work
values
     dimens.xml
           <resources>
              <dimen name="default_text_size">20sp</dimen>
              <dimen name="default_large_text_size">30sp</dimen>
              <dimen name="splash_vertical_spacing">20dp</dimen>
              <dimen name="gauntface_tag_bottom_spacing">20dp</dimen>
              <dimen name="gauntface_tag_padding">5dp</dimen>
              <dimen name="gauntface_tag_radius">10dp</dimen>
              <dimen name="splash_gauntface_progress_bar">30dp</dimen>
              <dimen name="generic_dialog_padding">15dp</dimen>
              <dimen name="generic_dialog_bg_radius">4dp</dimen>
              <dimen name="generic_dialog_title_spacer_height">4dp</dimen>
              <dimen name="generic_dialog_title_spacer_vertical_spacing">10dp</dimen>
              <dimen name="sync_info_padding">10dp</dimen>
              <dimen name="sync_info_title_text_size">35sp</dimen>
              <dimen name="sync_info_msg_text_size">20sp</dimen>
              <dimen name="sync_info_bg_radius">10dp</dimen>
              <dimen name="sync_info_prof_pic_radius">8dp</dimen>
              <dimen name="sync_info_prof_pic_size">128dp</dimen>
          </resources>

values-land
     dimens.xml
           <resources>
              <dimen name="default_text_size">15sp</dimen>
              <dimen name="default_large_text_size">25sp</dimen>
              <dimen name="splash_vertical_spacing">10dp</dimen>
          </resources>
Tips to Reduce Work
   values      values-land
Tips to Reduce Work

          2
 Learn the ways of the
     nine patch
Tips to Reduce Work
Tips to Reduce Work

          3
Use <Shape> drawables
Tips to Reduce Work
<shape
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <gradient
        android:angle="0"
        android:endColor="@color/dark_blue"
        android:gradientRadius="660"
        android:startColor="@color/splash_light_blue"
        android:type="radial" />
</shape>
Tips to Reduce Work
Tips to Reduce Work

                             4
 Use Themes & Styles
  www.gauntface.co.uk/blog/2011/01/18/android-ui-reference
Tips to Reduce Work
values
     themes.xml
          <resources>
               <style name="Theme.FacebookSync" parent="@style/Theme.FacebookSync.Support">
                  ...
              </style>
              <style name="Theme.FacebookSync.NoTitleBar">
                  ...
              </style>
              <style name="Theme.FacebookSync.Dialog" parent="@style/Theme.Dialog.Support">
                  ...
               </style>
          </resources>

values-v11
     themes-v11.xml
          <resources>
              <style name="Theme.FacebookSync.Support" parent="@android:style/Theme.Holo"></style>
              <style name="Theme.Dialog.Support" parent="@android:style/Theme.Holo.Dialog"></style>
          </resources>

values-v4
     themes-v4.xml
          <resources>
              <style name="Theme.FacebookSync.Support" parent="@android:style/Theme.NoTitleBar"></style>
              <style name="Theme.Dialog.Support" parent="@android:style/Theme.Dialog"></style>
          </resources>
Tips to Reduce Work
Tips to Reduce Work

           5
Give up control - be fluid
Tips to Reduce Work
     Note: Not the best example ;)
Tips to Reduce Work
You’re Results May Vary
Thanks :)
    @gauntface
matt@gauntface.co.uk

Mais conteúdo relacionado

Semelhante a Android Fragment-Awesome

Elephant in the room: A DBA's Guide to Hadoop
Elephant in the room: A DBA's Guide to HadoopElephant in the room: A DBA's Guide to Hadoop
Elephant in the room: A DBA's Guide to Hadoop
Stuart Ainsworth
 
Breaking the oracle tie
Breaking the oracle tieBreaking the oracle tie
Breaking the oracle tie
agiamas
 
Distributed Data Analysis with Hadoop and R - Strangeloop 2011
Distributed Data Analysis with Hadoop and R - Strangeloop 2011Distributed Data Analysis with Hadoop and R - Strangeloop 2011
Distributed Data Analysis with Hadoop and R - Strangeloop 2011
Jonathan Seidman
 

Semelhante a Android Fragment-Awesome (20)

Androidfragment
AndroidfragmentAndroidfragment
Androidfragment
 
Introduction to mobile programming with Androids.
Introduction to mobile programming with Androids. Introduction to mobile programming with Androids.
Introduction to mobile programming with Androids.
 
Android training day 3
Android training day 3Android training day 3
Android training day 3
 
Supporting multi screen in android
Supporting multi screen in androidSupporting multi screen in android
Supporting multi screen in android
 
Supporting multi screen in android cn
Supporting multi screen in android cnSupporting multi screen in android cn
Supporting multi screen in android cn
 
Android supporting multiple screen
Android supporting multiple screenAndroid supporting multiple screen
Android supporting multiple screen
 
Introduction to Big Data and Hadoop
Introduction to Big Data and HadoopIntroduction to Big Data and Hadoop
Introduction to Big Data and Hadoop
 
Android在多屏幕、多设备上的适配 | 布丁 任斐
Android在多屏幕、多设备上的适配 | 布丁 任斐Android在多屏幕、多设备上的适配 | 布丁 任斐
Android在多屏幕、多设备上的适配 | 布丁 任斐
 
TDC2012 Android - Deixando Sua Interface mais Bonita com Shapes
TDC2012 Android - Deixando Sua Interface mais Bonita com ShapesTDC2012 Android - Deixando Sua Interface mais Bonita com Shapes
TDC2012 Android - Deixando Sua Interface mais Bonita com Shapes
 
Fernando F. Gallego - Efficient Android Resources 101
Fernando F. Gallego - Efficient Android Resources 101Fernando F. Gallego - Efficient Android Resources 101
Fernando F. Gallego - Efficient Android Resources 101
 
Let's dig into the Omega Theme!
Let's dig into the Omega Theme!Let's dig into the Omega Theme!
Let's dig into the Omega Theme!
 
Does my DIV look big in this?
Does my DIV look big in this?Does my DIV look big in this?
Does my DIV look big in this?
 
Hadoop Interview Questions and Answers
Hadoop Interview Questions and AnswersHadoop Interview Questions and Answers
Hadoop Interview Questions and Answers
 
Big Data - An Overview
Big Data -  An OverviewBig Data -  An Overview
Big Data - An Overview
 
Elephant in the room: A DBA's Guide to Hadoop
Elephant in the room: A DBA's Guide to HadoopElephant in the room: A DBA's Guide to Hadoop
Elephant in the room: A DBA's Guide to Hadoop
 
Bootstrap 3 training
Bootstrap 3 trainingBootstrap 3 training
Bootstrap 3 training
 
Breaking the oracle tie
Breaking the oracle tieBreaking the oracle tie
Breaking the oracle tie
 
Distributed Data Analysis with Hadoop and R - Strangeloop 2011
Distributed Data Analysis with Hadoop and R - Strangeloop 2011Distributed Data Analysis with Hadoop and R - Strangeloop 2011
Distributed Data Analysis with Hadoop and R - Strangeloop 2011
 
Hadoop Developer
Hadoop DeveloperHadoop Developer
Hadoop Developer
 
Introduction to Big Data & Hadoop
Introduction to Big Data & HadoopIntroduction to Big Data & Hadoop
Introduction to Big Data & Hadoop
 

Último

Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Último (20)

ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
AI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by Anitaraj
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptx
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 

Android Fragment-Awesome

  • 1. Android Fragment-Awesome Matthew Gaunt
  • 2. Who is this guy? • Master in Computer Science in Bristol • Senior Android Dev @ Mubaloo • Cross Platform Dev @ Future Platforms
  • 4. What’s coming up • Design - I can haz pretty • Dips • Buckets? • What buckets? • The story of buckets • Tips + Examples
  • 5. Dips Density Independent Pixels Abstract the screen size (think rounded corner rectangle) Never assume dip > pixels
  • 6. Buckets? ldpi mdpi hdpi xhdpi
  • 7. What Buckets? Screen density (ldpi, mdpi, hdpi, xhdpi) Orientation (port, land) Android Version (v4, v11) Screen size (small, normal, large, xlarge)
  • 8. Eeks lots of Images
  • 9. How to use Buckets • Images - [ldpi, mdpi, hdpi, xhdpi] [small, normal, large, xlarge] • Layout -[land, port] • Themes / Styles - [v4, v11] • Dimensions - [small, normal, large, xlarge]
  • 12. The History... ldpi <port> mdpi land hdpi 1.5 1.6
  • 13. The History... small ldpi normal <port> mdpi large land hdpi xlarge 1.5 1.6 3.0 (ish)
  • 14. The History... small ldpi normal ldpi mdpi <port> mdpi large hdpi land hdpi xlarge xhdpi 1.5 1.6 3.0 (ish) 4.0
  • 15. Recap • Lots of buckets • Lots of resources to apply the buckets to • How it relates to other platforms like iOS
  • 17. Phones / Tablets? ldpi mdpi hdpi xhdpi total Small 1.7% 2.4% 4.1% Normal 0.7% 18.5% 66.3% 2.5% 88.0% Large 0.2% 2.8% 3.0% XLarge 4.9% 4.9% ldpi mdpi mdpi hdpi ? hdpi ? xhdpi ? xhdpi ? Phones Tablets normal / small large / xlarge
  • 18. Hitting Both? drawable For all buckets drawable-ldpi drawable-mdpi Base drawable-hdpi drawable-xhdpi drawable-large-? Additional drawable-xlarge-?
  • 19. Tips to Reduce Work 1 Use values everywhere (dimens, ints, etc.)
  • 20. Tips to Reduce Work values dimens.xml <resources>         <dimen name="default_text_size">20sp</dimen>         <dimen name="default_large_text_size">30sp</dimen>         <dimen name="splash_vertical_spacing">20dp</dimen>         <dimen name="gauntface_tag_bottom_spacing">20dp</dimen>         <dimen name="gauntface_tag_padding">5dp</dimen>         <dimen name="gauntface_tag_radius">10dp</dimen>         <dimen name="splash_gauntface_progress_bar">30dp</dimen>         <dimen name="generic_dialog_padding">15dp</dimen>         <dimen name="generic_dialog_bg_radius">4dp</dimen>         <dimen name="generic_dialog_title_spacer_height">4dp</dimen>         <dimen name="generic_dialog_title_spacer_vertical_spacing">10dp</dimen>         <dimen name="sync_info_padding">10dp</dimen>         <dimen name="sync_info_title_text_size">35sp</dimen>         <dimen name="sync_info_msg_text_size">20sp</dimen>         <dimen name="sync_info_bg_radius">10dp</dimen>         <dimen name="sync_info_prof_pic_radius">8dp</dimen>         <dimen name="sync_info_prof_pic_size">128dp</dimen>     </resources> values-land dimens.xml <resources>         <dimen name="default_text_size">15sp</dimen>         <dimen name="default_large_text_size">25sp</dimen>         <dimen name="splash_vertical_spacing">10dp</dimen>     </resources>
  • 21. Tips to Reduce Work values values-land
  • 22. Tips to Reduce Work 2 Learn the ways of the nine patch
  • 24. Tips to Reduce Work 3 Use <Shape> drawables
  • 25. Tips to Reduce Work <shape     xmlns:android="http://schemas.android.com/apk/res/android"     android:shape="rectangle">     <gradient         android:angle="0"         android:endColor="@color/dark_blue"         android:gradientRadius="660"         android:startColor="@color/splash_light_blue"         android:type="radial" /> </shape>
  • 27. Tips to Reduce Work 4 Use Themes & Styles www.gauntface.co.uk/blog/2011/01/18/android-ui-reference
  • 28. Tips to Reduce Work values themes.xml <resources> <style name="Theme.FacebookSync" parent="@style/Theme.FacebookSync.Support">         ...     </style>     <style name="Theme.FacebookSync.NoTitleBar">         ...     </style>     <style name="Theme.FacebookSync.Dialog" parent="@style/Theme.Dialog.Support">         ... </style> </resources> values-v11 themes-v11.xml <resources>     <style name="Theme.FacebookSync.Support" parent="@android:style/Theme.Holo"></style>     <style name="Theme.Dialog.Support" parent="@android:style/Theme.Holo.Dialog"></style> </resources> values-v4 themes-v4.xml <resources>     <style name="Theme.FacebookSync.Support" parent="@android:style/Theme.NoTitleBar"></style>     <style name="Theme.Dialog.Support" parent="@android:style/Theme.Dialog"></style> </resources>
  • 30. Tips to Reduce Work 5 Give up control - be fluid
  • 31. Tips to Reduce Work Note: Not the best example ;)
  • 34. Thanks :) @gauntface matt@gauntface.co.uk