SlideShare a Scribd company logo
1 of 17
Android Supporting
Multiple screens
Allen Walker
allenlearntocode.com
allenatwork2012@gmail.com
ToC
• Terms & Concepts
• How to support multiple screens
• Configuration qualifers
• Alternative layout & drawable for multiple screens
• Configuration qualifers rules
• References & QA
Terms & Concepts
• Screen Size: small, normal, large, xlarge, …
• Screen Density: dot per inch – dpi (low, medium, high, xhigh, xxhigh)
• Orientation: land – port
• Resolution: 320* 480, 480*680, vv…
• Dependency independen pixel (dp)
px = dp * (dpi/160)
Screen Size & Density
• A set of four generalized sizes: small, normal, large, and xlarge
• xlarge screens are at least 960dp x 720dp
• large screens are at least 640dp x 480dp
• normal screens are at least 470dp x 320dp
• small screens are at least 426dp x 320dp
• A set of six generalized densities:
• ldpi (low) ~120dpi
• mdpi (medium) ~160dpi
• hdpi (high) ~240dpi
• xhdpi (extra-high) ~320dpi
• xxhdpi (extra-extra-high) ~480dpi
• xxxhdpi (extra-extra-extra-high) ~640dpi
How to Support Multiple Screens
1. Explicitly declare in the manifest which screen sizes your application
supports
2. Provide different bitmap drawables for different screen densities
3. Provide different layouts for different screen sizes
How to Support Multiple Screens(1)
“Explicitly declare in the manifest which screen sizes your application
supports”
• <supports-screens> element in your manifest file.
• Syntax : doc
<supports-screens android:resizeable=["true"| "false"]
android:smallScreens=["true" | "false"]
android:normalScreens=["true" | "false"]
android:largeScreens=["true" | "false"]
android:xlargeScreens=["true" | "false"]
android:anyDensity=["true" | "false"]
android:requiresSmallestWidthDp="integer"
android:compatibleWidthLimitDp="integer"
android:largestWidthLimitDp="integer"/>
How to Support Multiple Screens (2)
“Provide different bitmap drawables for different screen
densities”
• 3:4:6:8:12:16 scaling ratio
• For example, if you have a bitmap drawable that's 48x48 pixels for
medium-density screens. 
• Where to put drawable resources:
• res/drawable-mdpi/graphic.png
• res/drawable-hdpi/graphic.png
• res/drawable-xhdpi/graphic.png
• res/drawable-xxhdpi/graphic.png
36*36
72*72
96 * 96
How to Support Multiple Screens (3)
“Provide different layouts for different screen sizes”
Put different layout res into different folder
res/layout/my_layout.xml // layout for normal screen size ("default")
res/layout-large/my_layout.xml // layout for large screen size
res/layout-xlarge/my_layout.xml // layout for extra-large screen size
res/layout-xlarge-land/my_layout.xml
How to name those folder ?  configuration qualifiers
Configuration Qualifiers (1)
• Is: a string that you can append to a resource directory in your Android project and specifies the configuration
for which the resources inside are designed
• To: control how the system selects your alternative resources based on the characteristics of the current device
screen
• How: Create a new directory in your project's res/ directory and name it using the format:
<resources_name>-<qualifier>
• <resources_name> is the standard resource name:
drawable, layout, values
• <qualifier> is a configuration qualifier string !!!
Configuration Qualifiers (2)
• List Configuration
• MCC & MNC: mcc310, mcc310-mnc004
• Language & region: en, fr, en-rUS
• Layout direction: ldrtl, ldltr
• smallestWidth: sw<N>dp
• Avaialbe width: w<N>dp
• Available height: h<N>dp
• Screen size: small, normal, large, xlarge
• Screen aspect: long, notlong
• Round screen: round, notround
Configuration Qualifiers (3)
• List Configuration (continue…)
• Screen Orientation: port, land
• UI mode: car, desk, television, watch
• Night mode: night, notnight
• Screen density: ldpi, mdpi, hdpi, xhdpi, nodpi, tvdpi, anydpi
• Touch screen type : notouch, finger
• Keyboard availability: keysexposed, keyshidden
• Primary text input method: nokey, qwerty, 12key
• Navigation key availability: navexposed, navhidden
• Primary non-touch navigation method: nonav, dpad, trackball
• Platform Version (API level): v3, v4, v7
Configuration Qualifiers (4)
• Qualifier name rules (doc)
• can specify multiple qualifiers for a single set of resources, separated by dashes:
drawable-en-rUS-land
• The qualifiers must be in the order listed above
• Alternative resource directories cannot be nested
• Values are case-insensitive
• Only one value for each qualifier type is supported
Decraling layout
The old way & new way
• The old way: put layout into res/layout-xlarge ( tablet)
• First generation, android 3.0
• The new way: base on amount of space you needed (such as you need 600dp of width)
• New qualifiers: smallestwidth, available width, available height
• sw<N>dp, w<N>dp, h<N>dp
• Typical screen width:
• 320dp: a typical phone screen (240x320 ldpi, 320x480 mdpi, 480x800 hdpi, etc).
• 480dp: a tweener tablet like the Streak (480x800 mdpi).
• 600dp: a 7” tablet (600x1024 mdpi).
• 720dp: a 10” tablet (720x1280 mdpi, 800x1280 mdpi, etc).
• So layout folder will be:
• res/layout/main_activity.xml # For handsets (smaller than 600dp available width)
• res/layout-sw600dp/main_activity.xml # For 7” tablets (600dp wide and bigger)
• res/layout-sw720dp/main_activity.xml # For 10” tablets (720dp wide and bigger)
• So new way of declaring screen size support in manifest
Best Practice
• Use wrap_content, match_parent, or dp units when specifying
dimensions in an XML layout file
• Do not use hard coded pixel values in your application code
• Do not use AbsoluteLayout (it's deprecated)
• Supply alternative bitmap drawables for different screen densities
Case study: Google Iosched
Drawable Layout Mipmap
Values
Refercences
• https://developer.android.com/guide/practices/screens_support.html
• https://developer.android.com/guide/topics/resources/providing-resources.html
• https://developer.android.com/guide/topics/manifest/supports-screens-element.html
• http://www.slideshare.net/rffffffff007/supporting-multi-screen-in-android-cn?qid=363a1eec-1702-4fb4-acc1-
e6d3c47d4e3f&v=&b=&from_search=8
Q & A
• allenlearntocode.com
• Allenatwork2012@gmail.com

More Related Content

Similar to Android supporting multiple screen

Etsy - Android & Design
Etsy - Android & DesignEtsy - Android & Design
Etsy - Android & DesignDeniz Veli
 
Android resources
Android resourcesAndroid resources
Android resourcesma-polimi
 
Android在多屏幕、多设备上的适配 | 布丁 任斐
Android在多屏幕、多设备上的适配 | 布丁 任斐Android在多屏幕、多设备上的适配 | 布丁 任斐
Android在多屏幕、多设备上的适配 | 布丁 任斐imShining @DevCamp
 
Android training day 3
Android training day 3Android training day 3
Android training day 3Vivek Bhusal
 
Get ready for new nexus devices
Get ready for new nexus devicesGet ready for new nexus devices
Get ready for new nexus devicesKetan Raval
 
Responsive Web Design & APEX Theme 25 (OGh APEX World 2014)
Responsive Web Design & APEX Theme 25 (OGh APEX World 2014)Responsive Web Design & APEX Theme 25 (OGh APEX World 2014)
Responsive Web Design & APEX Theme 25 (OGh APEX World 2014)Christian Rokitta
 
Bringing Structure, Scalability, and Services to Cloud-Scale Storage
Bringing Structure, Scalability, and Services to Cloud-Scale StorageBringing Structure, Scalability, and Services to Cloud-Scale Storage
Bringing Structure, Scalability, and Services to Cloud-Scale StorageMapR Technologies
 
Big data processing meets non-volatile memory: opportunities and challenges
Big data processing meets non-volatile memory: opportunities and challenges Big data processing meets non-volatile memory: opportunities and challenges
Big data processing meets non-volatile memory: opportunities and challenges DataWorks Summit
 
TriHUG - Beyond Batch
TriHUG - Beyond BatchTriHUG - Beyond Batch
TriHUG - Beyond Batchboorad
 
CSS3: Simply Responsive
CSS3: Simply ResponsiveCSS3: Simply Responsive
CSS3: Simply ResponsiveDenise Jacobs
 
Android Fragment-Awesome
Android Fragment-AwesomeAndroid Fragment-Awesome
Android Fragment-AwesomeGauntFace
 
Putting Apache Drill into Production
Putting Apache Drill into ProductionPutting Apache Drill into Production
Putting Apache Drill into ProductionMapR Technologies
 
Processing Drone data @Scale
Processing Drone data @ScaleProcessing Drone data @Scale
Processing Drone data @ScaleDr Hajji Hicham
 
Responsive Web Design
Responsive Web DesignResponsive Web Design
Responsive Web DesignManjunatha D
 

Similar to Android supporting multiple screen (20)

Chapter 9 - Resources System
Chapter 9 - Resources SystemChapter 9 - Resources System
Chapter 9 - Resources System
 
Etsy - Android & Design
Etsy - Android & DesignEtsy - Android & Design
Etsy - Android & Design
 
Android resources
Android resourcesAndroid resources
Android resources
 
Android在多屏幕、多设备上的适配 | 布丁 任斐
Android在多屏幕、多设备上的适配 | 布丁 任斐Android在多屏幕、多设备上的适配 | 布丁 任斐
Android在多屏幕、多设备上的适配 | 布丁 任斐
 
Android training day 3
Android training day 3Android training day 3
Android training day 3
 
Responsive web - CC FE & UX
Responsive web -  CC FE & UXResponsive web -  CC FE & UX
Responsive web - CC FE & UX
 
Hadoop - Introduction to Hadoop
Hadoop - Introduction to HadoopHadoop - Introduction to Hadoop
Hadoop - Introduction to Hadoop
 
Drill dchug-29 nov2012
Drill dchug-29 nov2012Drill dchug-29 nov2012
Drill dchug-29 nov2012
 
Get ready for new nexus devices
Get ready for new nexus devicesGet ready for new nexus devices
Get ready for new nexus devices
 
Responsive Web Design & APEX Theme 25 (OGh APEX World 2014)
Responsive Web Design & APEX Theme 25 (OGh APEX World 2014)Responsive Web Design & APEX Theme 25 (OGh APEX World 2014)
Responsive Web Design & APEX Theme 25 (OGh APEX World 2014)
 
Bringing Structure, Scalability, and Services to Cloud-Scale Storage
Bringing Structure, Scalability, and Services to Cloud-Scale StorageBringing Structure, Scalability, and Services to Cloud-Scale Storage
Bringing Structure, Scalability, and Services to Cloud-Scale Storage
 
Big data processing meets non-volatile memory: opportunities and challenges
Big data processing meets non-volatile memory: opportunities and challenges Big data processing meets non-volatile memory: opportunities and challenges
Big data processing meets non-volatile memory: opportunities and challenges
 
TriHUG - Beyond Batch
TriHUG - Beyond BatchTriHUG - Beyond Batch
TriHUG - Beyond Batch
 
CSS3: Simply Responsive
CSS3: Simply ResponsiveCSS3: Simply Responsive
CSS3: Simply Responsive
 
Big data
Big dataBig data
Big data
 
Android Fragment-Awesome
Android Fragment-AwesomeAndroid Fragment-Awesome
Android Fragment-Awesome
 
Putting Apache Drill into Production
Putting Apache Drill into ProductionPutting Apache Drill into Production
Putting Apache Drill into Production
 
Hadoop and Distributed Computing
Hadoop and Distributed ComputingHadoop and Distributed Computing
Hadoop and Distributed Computing
 
Processing Drone data @Scale
Processing Drone data @ScaleProcessing Drone data @Scale
Processing Drone data @Scale
 
Responsive Web Design
Responsive Web DesignResponsive Web Design
Responsive Web Design
 

Recently uploaded

Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfhans926745
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdfChristopherTHyatt
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 

Recently uploaded (20)

Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 

Android supporting multiple screen

  • 1. Android Supporting Multiple screens Allen Walker allenlearntocode.com allenatwork2012@gmail.com
  • 2. ToC • Terms & Concepts • How to support multiple screens • Configuration qualifers • Alternative layout & drawable for multiple screens • Configuration qualifers rules • References & QA
  • 3. Terms & Concepts • Screen Size: small, normal, large, xlarge, … • Screen Density: dot per inch – dpi (low, medium, high, xhigh, xxhigh) • Orientation: land – port • Resolution: 320* 480, 480*680, vv… • Dependency independen pixel (dp) px = dp * (dpi/160)
  • 4. Screen Size & Density • A set of four generalized sizes: small, normal, large, and xlarge • xlarge screens are at least 960dp x 720dp • large screens are at least 640dp x 480dp • normal screens are at least 470dp x 320dp • small screens are at least 426dp x 320dp • A set of six generalized densities: • ldpi (low) ~120dpi • mdpi (medium) ~160dpi • hdpi (high) ~240dpi • xhdpi (extra-high) ~320dpi • xxhdpi (extra-extra-high) ~480dpi • xxxhdpi (extra-extra-extra-high) ~640dpi
  • 5. How to Support Multiple Screens 1. Explicitly declare in the manifest which screen sizes your application supports 2. Provide different bitmap drawables for different screen densities 3. Provide different layouts for different screen sizes
  • 6. How to Support Multiple Screens(1) “Explicitly declare in the manifest which screen sizes your application supports” • <supports-screens> element in your manifest file. • Syntax : doc <supports-screens android:resizeable=["true"| "false"] android:smallScreens=["true" | "false"] android:normalScreens=["true" | "false"] android:largeScreens=["true" | "false"] android:xlargeScreens=["true" | "false"] android:anyDensity=["true" | "false"] android:requiresSmallestWidthDp="integer" android:compatibleWidthLimitDp="integer" android:largestWidthLimitDp="integer"/>
  • 7. How to Support Multiple Screens (2) “Provide different bitmap drawables for different screen densities” • 3:4:6:8:12:16 scaling ratio • For example, if you have a bitmap drawable that's 48x48 pixels for medium-density screens.  • Where to put drawable resources: • res/drawable-mdpi/graphic.png • res/drawable-hdpi/graphic.png • res/drawable-xhdpi/graphic.png • res/drawable-xxhdpi/graphic.png 36*36 72*72 96 * 96
  • 8. How to Support Multiple Screens (3) “Provide different layouts for different screen sizes” Put different layout res into different folder res/layout/my_layout.xml // layout for normal screen size ("default") res/layout-large/my_layout.xml // layout for large screen size res/layout-xlarge/my_layout.xml // layout for extra-large screen size res/layout-xlarge-land/my_layout.xml How to name those folder ?  configuration qualifiers
  • 9. Configuration Qualifiers (1) • Is: a string that you can append to a resource directory in your Android project and specifies the configuration for which the resources inside are designed • To: control how the system selects your alternative resources based on the characteristics of the current device screen • How: Create a new directory in your project's res/ directory and name it using the format: <resources_name>-<qualifier> • <resources_name> is the standard resource name: drawable, layout, values • <qualifier> is a configuration qualifier string !!!
  • 10. Configuration Qualifiers (2) • List Configuration • MCC & MNC: mcc310, mcc310-mnc004 • Language & region: en, fr, en-rUS • Layout direction: ldrtl, ldltr • smallestWidth: sw<N>dp • Avaialbe width: w<N>dp • Available height: h<N>dp • Screen size: small, normal, large, xlarge • Screen aspect: long, notlong • Round screen: round, notround
  • 11. Configuration Qualifiers (3) • List Configuration (continue…) • Screen Orientation: port, land • UI mode: car, desk, television, watch • Night mode: night, notnight • Screen density: ldpi, mdpi, hdpi, xhdpi, nodpi, tvdpi, anydpi • Touch screen type : notouch, finger • Keyboard availability: keysexposed, keyshidden • Primary text input method: nokey, qwerty, 12key • Navigation key availability: navexposed, navhidden • Primary non-touch navigation method: nonav, dpad, trackball • Platform Version (API level): v3, v4, v7
  • 12. Configuration Qualifiers (4) • Qualifier name rules (doc) • can specify multiple qualifiers for a single set of resources, separated by dashes: drawable-en-rUS-land • The qualifiers must be in the order listed above • Alternative resource directories cannot be nested • Values are case-insensitive • Only one value for each qualifier type is supported
  • 13. Decraling layout The old way & new way • The old way: put layout into res/layout-xlarge ( tablet) • First generation, android 3.0 • The new way: base on amount of space you needed (such as you need 600dp of width) • New qualifiers: smallestwidth, available width, available height • sw<N>dp, w<N>dp, h<N>dp • Typical screen width: • 320dp: a typical phone screen (240x320 ldpi, 320x480 mdpi, 480x800 hdpi, etc). • 480dp: a tweener tablet like the Streak (480x800 mdpi). • 600dp: a 7” tablet (600x1024 mdpi). • 720dp: a 10” tablet (720x1280 mdpi, 800x1280 mdpi, etc). • So layout folder will be: • res/layout/main_activity.xml # For handsets (smaller than 600dp available width) • res/layout-sw600dp/main_activity.xml # For 7” tablets (600dp wide and bigger) • res/layout-sw720dp/main_activity.xml # For 10” tablets (720dp wide and bigger) • So new way of declaring screen size support in manifest
  • 14. Best Practice • Use wrap_content, match_parent, or dp units when specifying dimensions in an XML layout file • Do not use hard coded pixel values in your application code • Do not use AbsoluteLayout (it's deprecated) • Supply alternative bitmap drawables for different screen densities
  • 15. Case study: Google Iosched Drawable Layout Mipmap Values
  • 16. Refercences • https://developer.android.com/guide/practices/screens_support.html • https://developer.android.com/guide/topics/resources/providing-resources.html • https://developer.android.com/guide/topics/manifest/supports-screens-element.html • http://www.slideshare.net/rffffffff007/supporting-multi-screen-in-android-cn?qid=363a1eec-1702-4fb4-acc1- e6d3c47d4e3f&v=&b=&from_search=8
  • 17. Q & A • allenlearntocode.com • Allenatwork2012@gmail.com

Editor's Notes

  1. Android supports several configuration qualifiers that allow you to control how the system selects your alternative resources based on the characteristics of the current device screen. A configuration qualifier is a string that you can append to a resource directory in your Android project and specifies the configuration for which the resources inside are designed.