One Size Fits All Sprint

  • Upload
    ttunguz

  • View
    219

  • Download
    0

Embed Size (px)

Citation preview

  • 8/14/2019 One Size Fits All Sprint

    1/32

    Creating one APK for multiple screen

    One Size Fits All

    Tuesday, October 27, 2009

  • 8/14/2019 One Size Fits All Sprint

    2/32

    That was then...

    Tuesday, October 27, 2009

  • 8/14/2019 One Size Fits All Sprint

    3/32

    ...this is now...

    Tuesday, October 27, 2009

  • 8/14/2019 One Size Fits All Sprint

    4/32

    ...this is now...

    Tuesday, October 27, 2009

  • 8/14/2019 One Size Fits All Sprint

    5/32

    ...this is now...HVGA

    QVGA

    WVGA

    Tuesday, October 27, 2009

  • 8/14/2019 One Size Fits All Sprint

    6/32

    ...what the future holdsHVGA

    QVGA

    WVGA

    Tuesday, October 27, 2009

  • 8/14/2019 One Size Fits All Sprint

    7/32

    ...what the future holdsHVGA

    QVGA

    WVGA

    Tuesday, October 27, 2009

  • 8/14/2019 One Size Fits All Sprint

    8/32

    Agenda

    Basics of multiple screens

    What your application can do

    What Android can do

    Tuesday, October 27, 2009

  • 8/14/2019 One Size Fits All Sprint

    9/32

    Multi Screen Basics

    Tuesday, October 27, 2009

  • 8/14/2019 One Size Fits All Sprint

    10/32

    Physical Size

    QVGA HVGAWVGA

    Tuesday, October 27, 2009

  • 8/14/2019 One Size Fits All Sprint

    11/32

  • 8/14/2019 One Size Fits All Sprint

    12/32

    Available Pixels

    WVGA

    QVGA

    HVGA

    Tuesday, October 27, 2009

  • 8/14/2019 One Size Fits All Sprint

    13/32

    Resource resolution

    $resource_type-$qualifier1-$qualifier2-...

    drawable-normal-hdpidrawable-notlong-port-normal-ldpidrawable-fr-rCA-large-long-land-mdpi-finger-keyssoft

    Tuesday, October 27, 2009

  • 8/14/2019 One Size Fits All Sprint

    14/32

    Pardon the mess

    Resource resolution

    $resource_type-$qualifier1-$qualifier2-...

    drawable-normal-hdpi-v4drawable-notlong-port-normal-ldpi-v4drawable-fr-rCA-large-long-land-mdpi-finger-v3

    Tuesday, October 27, 2009

  • 8/14/2019 One Size Fits All Sprint

    15/32

    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

  • 8/14/2019 One Size Fits All Sprint

    16/32

    Developer Goals

    Build best app for every configuration

    Crisp graphics Maximum use of screen space

    Minimize of complexity

    Tuesday, October 27, 2009

  • 8/14/2019 One Size Fits All Sprint

    17/32

  • 8/14/2019 One Size Fits All Sprint

    18/32

    Steps to optimization

    AndroidManifest.xml: tell the system what you support

    Provide custom drawables

    Create custom layouts

    Tuesday, October 27, 2009

  • 8/14/2019 One Size Fits All Sprint

    19/32

    Telling Android what you support

    AndroidManifest.xml

    Tuesday, October 27, 2009

  • 8/14/2019 One Size Fits All Sprint

    20/32

    Considering Density

    QVGA HVGA WVGA

    Tuesday, October 27, 2009

  • 8/14/2019 One Size Fits All Sprint

    21/32

    What density are default resources?

    Considering Density

    Tuesday, October 27, 2009

  • 8/14/2019 One Size Fits All Sprint

    22/32

  • 8/14/2019 One Size Fits All Sprint

    23/32

    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

  • 8/14/2019 One Size Fits All Sprint

    24/32

    SiP-ing and DIP-ing your way to success

    Building good layouts

    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

  • 8/14/2019 One Size Fits All Sprint

    25/32

    Working wtih UI dimensions in Java code

    Pixel Math

    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

  • 8/14/2019 One Size Fits All Sprint

    26/32

    Just in case...

    Ask not what Android can do

    for you, ask what you can dofor Android.

    Tuesday, October 27, 2009

  • 8/14/2019 One Size Fits All Sprint

    27/32

  • 8/14/2019 One Size Fits All Sprint

    28/32

    Resource pre-scaling

    In the platform from day 1 Always happens

    hdpi resource displayed on ldpi screen is 2X downsampled

    Tuesday, October 27, 2009

  • 8/14/2019 One Size Fits All Sprint

    29/32

    Resource pre-scaling

    In the platform from day 1 Always happens

    hdpi resource displayed on ldpi screen is 2X downsampled

    mdpi resource scaled up 1.5X on hdpi screens

    Tuesday, October 27, 2009

  • 8/14/2019 One Size Fits All Sprint

    30/32

    Density compatibility

    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

  • 8/14/2019 One Size Fits All Sprint

    31/32

    Size compatibility Stretching for !similar" screens

    Scaling to smaller screens

    Letter boxing on larger screens

    Tuesday, October 27, 2009

  • 8/14/2019 One Size Fits All Sprint

    32/32

    Q&A