Lecture #3 Supporting Different Devices
Different Languages Just copy and paste values. Add locale information. My. Project/ res/ values/ strings. xml values-fr/ strings. xml
Further steps. . . Change locale of your device To use appropriate string from Java: String hello = get. Resources(). get. String(R. string. hello_world); Text. View text. View = new Text. View(this); text. View. set. Text(R. string. hello_world);
Different Screens Screen Size The actual physical size, measured as the screen’s diagonal(small, normal, large, xlarge) Screen Density The quantity of pixels within a physical area of the screen(ldpi, mdpi, hdpi, xhdpi)
Sizes and Densities
Different Screen Layouts
Different Screen Layouts Portrait or Landscape My. Project/ res/ layout/ # default (portrait) main. xml layout-land/ # landscape main. xml layout-large/ # large (portrait) main. xml layout-large-land/ # large landscape main. xml
Different Screen Bitmaps Screen sizes • xlarge screens are at least 960 dp x 720 dp. • large screens are at least 640 dp x 480 dp. • normal screens are at least 470 dp x 320 dp. small screens are at least 426 dp x 320 dp.
Different Screen Bitmaps To generate images, use the following scaling: xhdpi: 2. 0 hdpi: 1. 5 mdpi: 1. 0 (baseline) ldpi: 0. 75 This means that if you generate a 200 x 200 image for xhdpi devices, you should generate the same resource in 150 x 150 for hdpi, 100 x 100 for mdpi, and 75 x 75 for ldpi devices
Examples A QVGA screen is 320 x 240 ldpi. Converting to mdpi (a 4/3 scaling factor) gives us 426 dp x 320 dp; The Xoom is a typical 10” tablet with a 1280 x 800 mdpi screen The Dell Streak is a 800 x 480 mdpi screen A typical 7” tablet has a 1024 x 600 mdpi screen
Quiz time What about Samsung Galaxy Tab? It has 1024 x 600 7” screen? • xlarge screens are at least 960 dp x 720 dp. • large screens are at least 640 dp x 480 dp. • normal screens are at least 470 dp x 320 dp. small screens are at least 426 dp x 320 dp.
Quiz time: The Samsung Galaxy Tab is an interesting case. Physically it is a 1024 x 600 7” screen and thus classified as “large”(hdpi) After applying ⅔ scaling factor the screen is 682 dp x 400 dp. The Tab actually reports that it is “large” but in fact it is “normal”
The end