Вы находитесь на странице: 1из 11

MyGOSSCON2010

Android User Interfaces:


Supporting Multiple Screens
Yap Wen Jiun
@wenjiun
Multimedia University Lecturer
CodeAndroid Malaysia Member

   
Growing Number of Android Devices

Low-end
Phones Tablets

 
High-end
 
Phones
Generalized Density and Size

ldpi:low mdpi: medium hdpi: high

   
Some Statistics

http://developer.android.com/resources/dashboard/screens.html
   
Testing on Emulators

http://developer.android.com/guide/developing/tools/emulator.html
   
Screen Supports in Manifest

Within <manifest> element in AndroidManifest.xml

<supports-screens
android:smallScreens = "true"
android:normalScreens = "true"
android:largeScreens = "true"
android:anyDensity = "true" />

   
Using Resource Qualifiers

Size Aspect ratio Density


● small ● long ● ldpi
● normal ● notlong ● mdpi
● large ● hdpi
● nodpi
For example:
res/layout-small/main.xml
res/drawable-large-long-hdpi/android.png

http://developer.android.com/guide/topics/resources/providing-
resources.html
   
Using dp & sp to Define Size

Why using dp (density-independent pixel)?


● 100dp means 75px on QVGA at 120 density
● 100dp means 100px on HVGA at 160 density
● 100dp means 150px on WVGA at 240 density
Therefore, we will get rougly the same physical size.

Using sp (scale-independent pixel) for fonts


● sp is similar with dp but also scaled by the user's font
size preference

   
Draw 9-patch

   
References

Books
 Beginning Android 2
http://apress.com/book/view/9781430226291

Android Developers
 http://developer.android.com/

   
Thank you

Check out CodeAndroid Malaysia at


http://www.codeandroid.my/

● Small portions of this presentation are modifications based on work created


and shared by Google and used according to terms described in the Creative
Commons 3.0 Attribution License.

   

Вам также может понравиться