SLIDE 1
Coding ¡for ¡Different ¡Android ¡ Screen ¡sizes ¡and ¡Density ¡
By ¡Robin ¡Srivastava ¡
SLIDE 2 Intended ¡Audience ¡
- Developers ¡of ¡Android ¡apps ¡
- Any ¡technological ¡enthusiast ¡
- Any ¡enthusiast ¡
SLIDE 3 Ques?ons ¡Answered ¡ ¡
- What ¡to ¡ask ¡from ¡a ¡graphic ¡designer? ¡
- What ¡to ¡do ¡once ¡the ¡graphic ¡designer ¡gives ¡
the ¡assets? ¡
- How ¡to ¡create ¡screen ¡layouts ¡which ¡are ¡
independent ¡of ¡screen-‑size ¡and ¡screen-‑ density? ¡
- What ¡screen-‑sizes ¡and ¡densi?es ¡are ¡available? ¡
- Your ¡ques?ons ¡
SLIDE 4
Why ¡is ¡this ¡so ¡important? ¡
Some ¡stats ¡first ¡
SLIDE 5
Stat ¡1 ¡– ¡Android ¡OS ¡Distribu?on ¡
SLIDE 6
Stat ¡2 ¡– ¡Screen ¡Size ¡and ¡Density ¡
SLIDE 7
Stat ¡2 ¡– ¡Screen ¡Size ¡and ¡Density ¡ (contd..) ¡
SLIDE 8 Back ¡to ¡the ¡previous ¡ques?on ¡
Why ¡is ¡it ¡so ¡important? ¡
- Simple ¡mathema?cs ¡would ¡suggest ¡that ¡we ¡have ¡4 ¡* ¡4 ¡= ¡16 ¡
different ¡varia?ons ¡of ¡android ¡screen ¡size ¡and ¡density. ¡ ¡
- Each ¡of ¡these ¡sizes ¡and ¡density ¡comes ¡in ¡a ¡range, ¡so ¡
theore?cally ¡speaking ¡its ¡infinite ¡
- Prac?cally, ¡out ¡of ¡16 ¡there ¡are ¡only ¡12 ¡varia?ons ¡to ¡consider ¡
with ¡a ¡very ¡reasonable ¡devia?on ¡
SLIDE 9 12 ¡screen ¡varia?ons? ¡
- Is ¡it ¡low ¡or ¡high? ¡
- Android ¡gives ¡an ¡op?on ¡to ¡have ¡different ¡
folders ¡for ¡different ¡varia?ons. ¡
- If ¡we ¡s?ck ¡to ¡it ¡religiously, ¡we ¡are ¡talking ¡
about ¡having ¡12 ¡set ¡of ¡graphics, ¡each ¡with ¡ different ¡specs ¡
SLIDE 10 12 ¡screen ¡varia?ons? ¡
- Is ¡it ¡low ¡or ¡high? ¡
- Android ¡gives ¡an ¡op?on ¡to ¡have ¡different ¡
folders ¡for ¡different ¡varia?ons. ¡
- If ¡we ¡s?ck ¡to ¡it ¡religiously, ¡we ¡are ¡talking ¡
about ¡having ¡12 ¡set ¡of ¡graphics, ¡each ¡with ¡ different ¡specs ¡
A ¡small ¡change ¡of ¡direc?on ¡or ¡shadow ¡in ¡an ¡ arrow ¡icon ¡will ¡require ¡changing/crea?ng ¡11 ¡ more ¡assets ¡
SLIDE 11 What ¡we ¡didn’t ¡consider ¡in ¡the ¡ previous ¡slides ¡
- Large ¡TVs ¡
- Small ¡watches ¡
SLIDE 12 What ¡to ¡ask ¡from ¡a ¡graphic ¡designer? ¡
- One ¡word ¡answer ¡– ¡graphical ¡assets ¡J ¡
SLIDE 13 What ¡to ¡ask ¡from ¡a ¡graphic ¡designer? ¡
- One ¡word ¡answer ¡– ¡graphical ¡assets ¡J ¡
- But ¡the ¡real ¡ques?on ¡is, ¡do ¡we ¡really ¡need ¡
that ¡asset ¡we ¡are ¡asking ¡for? ¡
SLIDE 14 Some ¡ques?ons ¡to ¡ask ¡yourself ¡before ¡ asking ¡for ¡assets ¡
- Do ¡I ¡really ¡need ¡the ¡assets ¡to ¡display ¡a ¡kind ¡
dialog ¡box? ¡
- Those ¡fancy ¡texts, ¡do ¡I ¡really ¡need ¡an ¡image ¡
for ¡it? ¡
- Those ¡colored ¡lines ¡being ¡used, ¡do ¡I ¡really ¡
need ¡them ¡as ¡a ¡separate ¡image? ¡
SLIDE 15 Giving ¡Rich ¡Look ¡Using ¡Views ¡
Color ¡code ¡#33B5E5 ¡ Font ¡Name ¡– ¡Roboto ¡ Color ¡Code ¡-‑ ¡#33B5E5 ¡
SLIDE 16 If ¡you ¡really ¡need ¡an ¡asset ¡
- Is ¡it ¡some ¡basic ¡shape ¡or ¡intricate ¡image? ¡
– If ¡its ¡shape ¡try ¡to ¡use ¡ShapeDrawable ¡(demo), ¡else ¡
- Take ¡the ¡PNG ¡
- Convert ¡it ¡into ¡9-‑patch ¡
SLIDE 17 9-‑patch ¡Image ¡
- Stretchable ¡bitmap ¡
- Define ¡the ¡area ¡in ¡which ¡the ¡text ¡appears ¡
SLIDE 18 9-‑patch ¡
– Tool ¡demo ¡ – App ¡demo ¡
SLIDE 19 When ¡9-‑patch ¡might ¡not ¡work ¡
- Images ¡with ¡text ¡in ¡it ¡and ¡the ¡requirement ¡is ¡
stretching ¡of ¡text ¡too ¡(without ¡making ¡it ¡look ¡ bad) ¡
- Images ¡which ¡requires ¡very ¡fine ¡shadowing ¡
and ¡gradients ¡
- Characters ¡and ¡cartoons ¡with ¡intricate ¡designs ¡
SLIDE 20 When ¡9-‑patch ¡might ¡not ¡work ¡ (contd…) ¡
- Need ¡different ¡images ¡for ¡different ¡resolu?on ¡
SLIDE 21 Providing ¡Alternate ¡Resources ¡
- <resource-‑name> ¡-‑ ¡<qualifier> ¡
- Famous ¡ones ¡
– drawable-‑hdpi ¡ – drawable-‑mdpi ¡
– drawable-‑fr-‑hdpi ¡ – drawable-‑sw600dp-‑hdpi ¡ – drawable-‑land ¡ – drawable-‑long ¡ – drawable-‑land-‑v8 ¡ – etc ¡
SLIDE 22
For ¡the ¡en?re ¡list ¡
Open ¡developers’ ¡manual ¡for ¡providing ¡resources ¡
SLIDE 23 How ¡to ¡create ¡screen ¡size ¡and ¡density ¡ independent ¡layout? ¡
- First, ¡let’s ¡check ¡out ¡various ¡common ¡screen ¡
sizes ¡and ¡densi?es ¡
SLIDE 24 Some ¡terminologies ¡we ¡will ¡use ¡
– Number ¡of ¡dots ¡per ¡inch ¡of ¡the ¡screen. ¡A ¡medium ¡ density ¡device ¡has ¡an ¡average ¡of ¡160 ¡dots-‑per-‑inch ¡
– Total ¡number ¡of ¡physical ¡pixels ¡
- Density ¡independent ¡pixel ¡(dp ¡or ¡dip) ¡
– The ¡density-‑independent ¡pixel ¡is ¡equivalent ¡to ¡one ¡ physical ¡pixel ¡on ¡a ¡160 ¡dpi ¡screen, ¡which ¡is ¡the ¡ baseline ¡density ¡assumed ¡by ¡the ¡system ¡for ¡a ¡ “medium” ¡density ¡screen ¡ – px ¡= ¡dp ¡* ¡(dpi ¡/ ¡160) ¡
SLIDE 25
Screen ¡Sizes ¡and ¡Density ¡Ranges ¡
SLIDE 26 Resolu?ons ¡in ¡the ¡form ¡of ¡DP ¡
- Xlarge ¡– ¡960dp ¡x ¡720dp ¡
- Large ¡– ¡640dp ¡x ¡480dp ¡
- Normal ¡– ¡470dp ¡x ¡320dp ¡
- Small ¡– ¡426dp ¡x ¡320dp ¡
SLIDE 27 Back ¡to ¡the ¡ques?on ¡
- How ¡to ¡create ¡layouts ¡which ¡are ¡independent ¡
- f ¡screen ¡sizes ¡and ¡densi?es? ¡
¡
DEMO ¡
SLIDE 28 Some ¡Quick ¡Tips ¡
- DO ¡NOT ¡use ¡px ¡as ¡the ¡unit ¡of ¡text ¡sizes ¡and ¡
views ¡
- Use ¡dp ¡while ¡giving ¡the ¡margins, ¡padding ¡or ¡
the ¡dimension ¡of ¡a ¡view ¡
- Give ¡the ¡text ¡size ¡is ¡sp ¡
SLIDE 29 Some ¡Quick ¡Tips ¡
Header ¡ Footer ¡ Content ¡
Use ¡ ¡ Linear ¡Layout ¡
SLIDE 30 Some ¡Quick ¡Tips ¡
When ¡alignment ¡ rela?ve ¡to ¡other ¡ components ¡ maper ¡– ¡use ¡ Rela?ve ¡Layout ¡ ¡ It ¡is ¡the ¡most ¡ general ¡layout ¡ which ¡can ¡be ¡ used ¡for ¡laying ¡
with ¡great ¡ flexibility ¡
SLIDE 31
SLIDE 32
E-‑mail ¡– ¡robin@paradigmcrea?ves.com ¡