One Size Fits All Creating one APK for multiple screen Tuesday, October 27, 2009
That was then...
Tuesday, October 27, 2009
...this is now...
Tuesday, October 27, 2009
...this is now...
Tuesday, October 27, 2009
...this is now... HVGA
WVGA
QVGA
Tuesday, October 27, 2009
...what the future holds HVGA
WVGA
QVGA
Tuesday, October 27, 2009
...what the future holds HVGA
WVGA
QVGA
Tuesday, October 27, 2009
Agenda
• • •
Basics of multiple screens What your application can do What Android can do
Tuesday, October 27, 2009
Multi Screen Basics
Tuesday, October 27, 2009
Physical Size
QVGA
Tuesday, October 27, 2009
HVGA
WVGA
Available Pixels
QVGA
Tuesday, October 27, 2009
HVGA
WVGA
Available Pixels
QVGA HVGA WVGA
Tuesday, October 27, 2009
Resource resolution
$resource_type-$qualifier1-$qualifier2-... drawable-normal-hdpi drawable-notlong-port-normal-ldpi drawable-fr-rCA-large-long-land-mdpi-finger-keyssoft
Tuesday, October 27, 2009
Resource resolution Pardon the mess
$resource_type-$qualifier1-$qualifier2-... drawable-normal-hdpi-v4 drawable-notlong-port-normal-ldpi-v4 drawable-fr-rCA-large-long-land-mdpi-finger-v3
Tuesday, October 27, 2009
Framework Goals • • • •
Present UI with physically consistent size Reduce complexity for developers Help apps run on unforeseen screens Allow full control if the app wants it
Tuesday, October 27, 2009
Developer Goals •
Build best app for every configuration
• •
•
Crisp graphics Maximum use of screen space
Minimize of complexity
Tuesday, October 27, 2009
Optimizing your apps
Ask not what Android can do for you, ask what you can do for Android.
Tuesday, October 27, 2009
Steps to optimization
• • •
AndroidManifest.xml: tell the system what you support Provide custom drawables Create custom layouts
Tuesday, October 27, 2009
AndroidManifest.xml Telling Android what you support
<uses-sdk android:minSdkVersion=”3” android:targetSdkVersion=”4” > <supports-screens android:smallScreens=”true” android:normalScreens=”true” android:largeScreens=”true” android:anyDensity=”true” />
Tuesday, October 27, 2009
Considering Density QVGA
Tuesday, October 27, 2009
HVGA
WVGA
Considering Density What density are default resources?
Tuesday, October 27, 2009
Considering Density What density are default resources?
160dpi Tuesday, October 27, 2009
Considering size • •
Screen space grows slower than resolution Adjust layouts to take advantage of screen space
•
•
RelativeLayout can help here
Screen sizes: small, normal, and large
Tuesday, October 27, 2009
Building good layouts SiP-ing and DIP-ing your way to success
•
Take a !sp" from column A
•
•
Considers screen density and user settings
And a !dip" in column B
•
Considers just screen density
Tuesday, October 27, 2009
Pixel Math Working wtih UI dimensions in Java code import android.util.DisplayMetrics; ... private int dipsToPixels(int dipValue) { DisplayMetrics thisDisplay = new DisplayMetrics(); Float dipSize = new Float( dipValue * thisDisplay.density); return dipSize.intValue(); }
Tuesday, October 27, 2009
Just in case...
Ask not what Android can do for you, ask what you can do for Android.
Tuesday, October 27, 2009
Resource pre-scaling • • •
In the platform from day 1 Always happens hdpi resource displayed on ldpi screen is 2X down sampled
Tuesday, October 27, 2009
Resource pre-scaling • • •
In the platform from day 1 Always happens hdpi resource displayed on ldpi screen is 2X down sampled
Tuesday, October 27, 2009
Resource pre-scaling • • • •
In the platform from day 1 Always happens hdpi resource displayed on ldpi screen is 2X down sampled mdpi resource scaled up 1.5X on hdpi screens
Tuesday, October 27, 2009
Density compatibility • •
<support-screens android:anyDensity=”false” /> Creates the illusion of being on an mdpi screen
• •
FWVGA, hdpi screen will report 569x320 Can convert to physical pixels using DisplayMetrics.density
Tuesday, October 27, 2009
Size compatibility • • •
Stretching for !similar" screens Scaling to smaller screens Letter boxing on larger screens
Tuesday, October 27, 2009
Q&A
Tuesday, October 27, 2009