• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Working with Multiple Android Screens
 

Working with Multiple Android Screens

on

  • 13,051 views

Make Your Android UI Rock Everywhere

Make Your Android UI Rock Everywhere
http://developer.motorola.com

Statistics

Views

Total Views
13,051
Views on SlideShare
6,557
Embed Views
6,494

Actions

Likes
8
Downloads
1
Comments
1

17 Embeds 6,494

http://developer.motorola.com 4907
https://developer.motorola.com 1032
http://community.developer.motorola.com 507
http://anna-desktop.am.mot.com 15
http://translate.googleusercontent.com 14
http://webcache.googleusercontent.com 4
https://sandbox.mdstage.com 2
http://pages-sandbox.mdstage.com 2
http://www.verious.com 2
http://paper.li 2
http://developer.motorola.com. 1
https://stage.mdstage.com 1
https://pages-sandbox.mdstage.com 1
http://twitc.com 1
http://208.74.204.202 1
http://localhost 1
url_unknown 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel

11 of 1 previous next

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
  • To download this document
    Action:
    1. Manual Next Page from 1 to 53
    2. Ctrl + S to save web page
    3. Open resource folder in File Explorer (Windows)
    4. Copy from slide-1-728.jpg to slide-53-728.jpg
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Working with Multiple Android Screens Working with Multiple Android Screens Presentation Transcript

    • Working with Multiple Screens
      Make Your Android UI Rock Everywhere
    • Suzanne Alexandra
      Android Developer Advocate, Motorola
      @suzalex
      http://moto.ly/samples
      © 2010 Motorola Mobility, Inc. All rights reserved except as otherwise explicitly indicated.
    • Why does it matter?
    • Make users happy Extend your reach
    • Size really mattersPause
      &
      Watch DialingWandhttp://moto.ly/dialingwand
    • Key Point #1Choose your target devices
    • Android 1.5? QVGA? Global?
      As of November 2010, developer.android.com
    • FLIPOUT
      DROID PRO
      DROID X
    • Comparing resolution
      DROID X480 x 854
      Normal
      DROID PRO320 x 480
      Normal
      FLIPOUT320 x 240
      Small
    • Comparing resolution
      DROID XHigh240 dpi
      DROID PROMedium160 dpi
      FLIPOUTLow120 dpi
    • Key Point #2Start with a fewsimple guidelines.
    • Pause the slides
      &
      watch the PhotoDemo video on YouTube
    • Adjust your AndroidManifestfor versions and screen sizes.
    • <uses-sdk android:minSdkVersion= "7"
      android:targetSdkVersion= "8" />
    • <supports-screens
      android:largeScreens= "true"
      android:normalScreens="true"
      android:smallScreens="true"
      android:anyDensity="true" />
    • But be careful
      • Make sure minSdkVersion has the API features you need
      • Test thoroughly on your targetSdkVersion
      • Make sure you don't get size compatibility mode
    • Use liquid, adaptable layouts.
      Try FrameLayout and RelativeLayout.
    • BonusScreen orientation and performance
    • Use adaptable measurements,like dip and sp.
    • Low
      1 dip = 0.75 pixels
      High
      1 dip = 1.5 pixels
      Medium
      1 dip = 1 pixel
      What’s a DIP?
      A pixel that changes size
    • Pause the slides
      &
      Watch the RelativeLayout video on YouTube
    • Use one set of images andlet Android scale them, for now.
      But we’ll look at this more later.
    • Key Point #3
      Add custom resources as needed, but watch performance.
    • Add custom layouts, if you need them.But you might not.
    • Choose an image strategy
      • One set of images and let Android autoscale?
      • Custom resource sets for low, medium, and high density?
      • Target the most commonly used density?
      • Retrieve images dynamically at runtime and handle?
    • 150% for high
      100% for normal
      75% for low
    • Memory vs file size
      PhotoOne 32 MBmemory
      324 KB size
      PhotoThree 23 MBmemory
      728 KB size
    • In other words
      Autoscaling uses memory.Custom image sets increase file size.
    • What happens if you load a really big image
      into a small view?
    • You might get
      No image
      Or a memory error
    • Your application UI can behave differently across devicesor in different conditionsdue to memory
    • Pause the slides
      &
      Watch the handling images video on YouTube
    • private Bitmap loadBitmap() {
      DisplayMetrics metrics = new DisplayMetrics();
      getWindowManager().getDefaultDisplay().getMetrics(metrics);
      int screenDensity = metrics.densityDpi;
      BitmapFactory.Options options = new BitmapFactory.Options();
      options.inJustDecodeBounds = false;
      options.inSampleSize = 4;
      options.inScaled = true;
      options.inTargetDensity = screenDensity;
      Bitmap bitmap = BitmapFactory.decodeResource(getResources(),
      R.drawable.clover, options);
      return bitmap;
      }
    • If you need to detect density at runtimeandroid.util.DisplayMetricsis cool
    • Pause the slides
      &Watch the detecting device density video on YouTube
    • 240 and 1.5
      120 and 0.75
      160 and 1.0
    • public void checkDensity() {
      DisplayMetrics metrics = new DisplayMetrics();
      getWindowManager().getDefaultDisplay().getMetrics(metrics);
      String logical_density = Float.toString(metrics.density);
      Log.e (TAG, "Logical density is " + logical_density);
      // for API level 4 (Android 1.6) and forward
      String screen_density = Integer.toString(metrics.densityDpi);
      Log.e (TAG, "Screen density is " + screen_density);
      }
    • Key Point #4
      Touch and gesture are key.
      Make sure they’re density independent too.
    • Pause the slides
      &Watch the buttons video on YouTube
    • <ImageButton
      android:id="@+id/button"
      android:src="@drawable/button"
      android:clickable="true"
      android:layout_gravity="center_vertical|center_horizontal"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:background="@null"
      android:padding="40dip"
      />
    • 16 pixels
      3.3 mm
      1.7 mm
      2.5 mm
    • private static final float DISTANCE_DIP = 16.0f;
      private static final float PATH_DIP = 40.0f;
      // convert dip measurements to pixels
      final float scale = getResources().getDisplayMetrics().density;
      scaledDistance = (int) ( DISTANCE_DIP * scale + 0.5f );
      scaledPath = (int) ( PATH_DIP * scale + 0.5f );
    • Okay ..
      Remember the key points?
    • Once again …
      • Choose your target devices.
      • Start with a few simple guidelines.
      • Add custom resources as needed, but watch performance.
      • Make sure touch and gesture are density independent too.
    • Thank youGraciasObrigada谢谢
      @suzalex@motodev
      http://moto.ly/samples
    • LICENSE AND TRADEMARK NOTICES
      Except where noted, sample source code written by Motorola Mobility Inc. and provided to you is licensed as described below.
      Copyright © 2010, Motorola, Inc. All rights reserved except as otherwise explicitly indicated.
      Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
      • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
      • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
      • Neither the name of the Motorola, Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
      THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
      Other source code displayed in this presentation may be licensed under Apache License, Version 2

      Copyright © 2010, Android Open Source Project. All rights reserved unless otherwise explicitly indicated.

      Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
      Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
      DROID is a trademark of Lucasfilm Ltd. and its related companies. Used under license.