SlideShare ist ein Scribd-Unternehmen logo
1 von 72
Suzanne Alexandra
Android Technology Evangelist
Motorola Mobility




Top Tips for Android UIs
Getting the Magic on Tablets



MOTOROLA and the Stylized M Logo are trademarks or registered trademarks of Motorola Trademark Holdings, LLC.
All other trademarks are the property of their respective owners. © 2011 Motorola Mobility, Inc. All rights reserved.
@suzalex
developer.motorola.com



        Presentation Title   Version 1.0   02.24.09
•Video here
We're in a whole new place.
Bring the right stuff aboard.




               Space Chips
        http://moto.ly/spacechips
Get the magic



01 KEEP ERGONOMICS THOUGHTFUL



02 ENGAGE THE SENSES



03 USE COOL AESTHETICS



04 MAKE IT OBVIOUS
Get the magic

01 KEEP ERGONOMICS THOUGHTFUL
    Landscape layouts
    Rich notifications
    Text sizes

02 ENGAGE THE SENSES
   Images
   Touchability

03 USE COOL AESTHETICS
   Themes, themes, themes

04 MAKE IT OBVIOUS
   Action bars
   Fragments
   Drag and drop
Assume your users are using landscape.
Landscape layouts
Landscape often needs specialized layouts, on any device
Landscape layouts
Look what happens on the tablet
Landscape layouts
What went wrong?

alignParentLeft                      alignParentRight




             Nothing in the center        Small image
Landscape layouts
Design for screen size AND orientation
Landscape layouts
The winning layout




                                         centerHorizontal="true"




                     <RelativeLayout>
layout_alignLeft     layout_alignRight
Landscape layouts
Optimize the user experience for wide screens
Landscape layouts
Avoid the wide, wide ocean effect
Text sizes
Small text (like images) probably won't work
Text sizes
Best practices




   Scale with sp
   18 sp and up
   Be sure text is readable to real users
Rich notifications
A key benefit of Android over other mobile platforms




                                     Your app notification
Rich notifications
Examples of when to use rich notifications



When new content arrives




                        When media is playing
Rich notifications
On Honeycomb, two notification displays




Tray




                         Popup
Rich notifications
Use the Notification.Builder class




Notification.Builder builder = new
            Notification.Builder( this );




Like AlertDialog.Builder
Rich notifications
Build the notification you want




 builder.setSmallIcon(R.drawable.icon)
   .setContentTitle(title)
   .setContentText(text)
   .setContentIntent(pintent) // A pending intent
   .setLargeIcon(myBitmap)
 ;
Rich notifications
Visual coding




  setLargeIcon()                           setSmallIcon()

                setContentTitle()
                                    setContentText()
Rich notifications
Get some magic - create a clickable button




 RemoteViews layout = new RemoteViews(
        getPackageName(), R.layout.notification);

 layout.setTextViewText(R.id.notification_title,
        getString(R.string.app_name));

 layout.setOnClickPendingIntent(R.id.notification_button,
    getDialogPendingIntent("Tapped") );

 builder.setContent(layout);
Rich notifications
Strategy for backward compatibility




private static boolean isHoneycomb =
      android.os.Build.VERSION.SDK_INT > 10;



if (!isHoneycomb)
      // start one activity intent
else
     // start another
Get the magic

01 KEEP ERGONOMICS THOUGHTFUL


02 ENGAGE THE SENSES
   Images
   Touchability


03 USE COOL AESTHETICS


04 MAKE IT OBVIOUS
Vision trumps all other senses.

                           Brain Rules
                     Dr. John Medina
Images
Express it visually, for appeal
Images
Screens for different devices need different image sizes
Images
Choose an image strategy




  One set of images and let Android autoscale?
  Custom resource sets for different sizes and densities?
  Target the most commonly used density?
  Retrieve images dynamically at runtime and scale for the device?
Images
Memory vs file size – an example




Autoscaling     32 MB memory
                324 KB size



Image sets       23 MB memory
                 728 KB size
Autoscaling uses memory.
Custom image sets increase file size.
Images
Sample large images at runtime to save memory




 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);
Images
 Where to place images and icons




                                   Default, auto-scaled

                                         High resolution icons
                                            Prescaled for density
Match 3.0 styling
Touchability
Tablets are designed for touch
Touchability
Make sure all targets are tappable
Touchability
Make sure all targets are tappable



  public View getView( int position,
         View convertView, ViewGroup parent) {

     ImageView i = new ImageView(mContext);
     i.setImageResource(mImageIds[position]);

     i.setLayoutParams(new Gallery.LayoutParams(
         300, 200));

     i.setScaleType(ImageView.ScaleType.FIT_XY);
     i.setBackgroundResource(
         mGalleryItemBackground);

     return i;
 }
Touchability
Watch how images transfer across devices




                                           160 dpi – medium
                                           16:9 aspect ratio
Get the magic

01 KEEP ERGONOMICS THOUGHTFUL




02 ENGAGE THE SENSES



03 USE COOL AESTHETICS
   Themes, themes, themes




04 MAKE IT OBVIOUS
Themes
Fit in with the device, or stand out
Themes
Honeycomb has two new holographic themes




                                      Theme.Holo




          Theme.Holo.Light
Themes
But they require hardware acceleration




  <application android:icon="@drawable/icon"
        android:label="@string/app_name"
        android:hardwareAccelerated="true" >




                                  Only available with Honeycomb
Themes
But you might be targeting multiple Android versions




    <uses-sdk android:minSdkVersion="8"
              android:targetSdkVersion="11"            />
Themes
Create multiple themes for Android versions




                              <style … parent=
                                 "@android:style/Theme">

                               <style … parent=
                                  "@android:style/Theme.Holo">
Be sure all API calls you use
work for all API versions you support.
Get the magic

01 KEEP ERGONOMICS THOUGHTFUL



02 ENGAGE THE SENSES


03 USE COOL AESTHETICS


04 MAKE IT OBVIOUS
   Action bars
   Fragments
   Drag and drop
Action bars
  Make your app features readily available




App icon            Drop-down dialog




      Action view                            Action items
Action bars
Visual coding


                          <item android:showAsAction="true" … >


                onCreateOptionsMenu()




android:actionLayout             onOptionsItemSelected()
android:actionViewClass
Action bars
Step 1 – Target API level 11



 <uses-sdk android:minSdkVersion="8"
           android:targetSdkVersion="11" />
Action bars
Step 2 – Place menu items on action bar




  <item android:id="@+id/favorite"
        android:title="@string/favorite"
        android:icon="@drawable/ic_menu_star"
        android:showAsAction="ifRoom" />
Action bars
Step 3 - Handle options selection as usual




@Override
 public boolean onOptionsItemSelected(MenuItem item) {

        switch (item.getItemId()) {
        case R.id.favorite:
            // do something
        return true;
    …
}
Action bars
On XOOM and smartphone
Action bars
Get some magic, style it




<style name="MyTheme"
       parent="android:style/Theme.Holo" >
   <item name="android:actionBarStyle">
              @style/ActionBar</item>
</style>


<style name="ActionBar"
       parent="android:style/Widget.Holo.ActionBar">
   <item name="android:background">
               @drawable/my_background</item>
</style>
Action bars
Get some magic, add a dialog




                               Use AlertDialog.Builder
                               Create a custom dialog in XML
                               Use a DialogFragment
Action bars
But do Honeycomb stuff only on Honeycomb




private static boolean isHoneycomb =
      android.os.Build.VERSION.SDK_INT > 10;


if (isHoneycomb) {
      // build custom dialog here
}
Fragments
Use to display more content and features, more fluidly
Fragments
You can use many patterns




                            Most common
Fragments
The starting fragment layout is the same across orientations
Fragments
But you can show or hide views
Fragments
In your main activity, find your fragments




 Fragment gridFrag =
       getFragmentManager().
       findFragmentById(R.id.photogrid);

 Fragment photoFrag =
       getFragmentManager().
       findFragmentById(R.id.the_frag);
Fragments
Check the orientation and adjust the views




 private boolean photoInline = false;

 photoInline = (photoFrag != null &&
         getResources().getConfiguration().orientation
         == Configuration.ORIENTATION_LANDSCAPE);

 if (photoInline) {
     // do something
 } else if ( photoFrag != null ) {
     getView().setVisibility(View.GONE);
 }
Fragments
Even better




     Animated transition
Fragments
Get some magic – animate fragment display #1



<set>
  <objectAnimator
       xmlns:android=
       http://schemas.android.com/apk/res/android

     android:propertyName="x"
     android:valueType="floatType"
     android:valueFrom="-1280"
     android:valueTo="0"
     android:duration="500"   />

</set>
Fragments
Get some magic – animate fragment display #2




FragmentTransaction ft =
       getFragmentManager().beginTransaction();

ft.setCustomAnimations( R.anim.slide_in_left,
       R.anim.slide_out_right );

DetailsFragment newFrag =DetailsFragment.newInstance();

ft.replace(R.id.details_fragment_container, newFrag,
       "detailFragment");

ft.commit();
Drag and drop
Creates direct, immediate physical engagement
Drag and drop
Has a number of event states




                                ACTION_DRAG_STARTED




                               ACTION_DRAG_ENTERED
Drag and drop
Has a number of event states




                                     ACTION_DROP
                               ACTION_DRAG_ENDED
Drag and drop
Watch how it works across fragments
Drag and drop
 Getting started #1




public boolean onDrag(View v, DragEvent event) {

 if (event.getAction() == DragEvent.ACTION_DRAG_STARTED){
      border = v.getBackground();
      v.setBackgroundDrawable(redBorder);
 } else if (event.getAction() ==
      DragEvent.ACTION_DRAG_ENTERED){
      isWithin = true;
 } else if (event.getAction() ==
      DragEvent.ACTION_DRAG_EXITED){
      isWithin = false;
 }

                                                   continued …
Drag and drop
Getting started #2




else if (event.getAction() == DragEvent.ACTION_DROP){
    if (isWithin){
       View view = (View) event.getLocalState();
       ViewGroup owner = (ViewGroup) view.getParent();
       owner.removeView(view);
       LinearLayout container = (LinearLayout) v;
       container.addView(view);
   }
   } else if (event.getAction() ==
       DragEvent.ACTION_DRAG_ENDED){
              v.setBackgroundDrawable(noBorder);
   }
  return true;
}
Questions?

       @suzalex
      @motodev
developer.motorola.com
thank you
LEGAL

LICENSE NOTICES

Except where noted, sample source code written by Motorola Mobility Inc. and provided to you is licensed as described below.
Copyright © 2010-2011, 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 offered under other licenses.

Apache 2.0
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.

Creative Commons 3.0 Attribution License
Portions of this presentation are reproduced from work created and shared by Google (http://code.google.com/policies.html) and used according to terms described in
   the Creative Commons 3.0 Attribution License (http://creativecommons.org/licenses/by/3.0/).

Weitere ähnliche Inhalte

Was ist angesagt?

iOS Human Interface Guidelines (HCI)
iOS Human Interface Guidelines (HCI)iOS Human Interface Guidelines (HCI)
iOS Human Interface Guidelines (HCI)Mohammad Khalil
 
Why the iPad UI matters, And how it differs from the Tablet PC, but also from...
Why the iPad UI matters, And how it differs from the Tablet PC, but also from...Why the iPad UI matters, And how it differs from the Tablet PC, but also from...
Why the iPad UI matters, And how it differs from the Tablet PC, but also from...Fabien Marry
 
Life Cycle of an iPhone App
Life Cycle of an iPhone AppLife Cycle of an iPhone App
Life Cycle of an iPhone AppJohn McKerrell
 
Programing for the iPhone
Programing for the iPhonePrograming for the iPhone
Programing for the iPhoneMike Qaissaunee
 
不能承受的感動 - iOS App實機測試
不能承受的感動 - iOS App實機測試不能承受的感動 - iOS App實機測試
不能承受的感動 - iOS App實機測試彼得潘 Pan
 
Designing better user interfaces
Designing better user interfacesDesigning better user interfaces
Designing better user interfacesJohan Ronsse
 
iPhone Development Overview
iPhone Development OverviewiPhone Development Overview
iPhone Development OverviewWilliam Taysom
 
Best Practice iPhone SDK App Design
Best Practice iPhone SDK App DesignBest Practice iPhone SDK App Design
Best Practice iPhone SDK App DesignBess Ho
 
iPad/iPhone - UI Design Resources
iPad/iPhone - UI Design ResourcesiPad/iPhone - UI Design Resources
iPad/iPhone - UI Design ResourcesMichael Moir
 
How to market your app
How to market your appHow to market your app
How to market your appOuriel Ohayon
 
iPhone - Human Interface Guidelines
iPhone - Human Interface GuidelinesiPhone - Human Interface Guidelines
iPhone - Human Interface GuidelinesMartin Ebner
 
iPhone Introduction
iPhone IntroductioniPhone Introduction
iPhone Introductionardiri
 
10 Design Commandments for Mobile App Developers
10 Design Commandments for Mobile App Developers10 Design Commandments for Mobile App Developers
10 Design Commandments for Mobile App DevelopersJigyasa Makkar
 
如何變成iOS App開發魔法師
如何變成iOS App開發魔法師如何變成iOS App開發魔法師
如何變成iOS App開發魔法師彼得潘 Pan
 
7 User Experience Lessons from the iPhone (Introducing UX)
7 User Experience Lessons from the iPhone (Introducing UX)7 User Experience Lessons from the iPhone (Introducing UX)
7 User Experience Lessons from the iPhone (Introducing UX)Stephen Anderson
 
iPhone transfer software
iPhone transfer softwareiPhone transfer software
iPhone transfer softwarejohnjuly123
 
Android 4.0 UI Design Tips
Android 4.0 UI Design TipsAndroid 4.0 UI Design Tips
Android 4.0 UI Design TipsJustin Lee
 

Was ist angesagt? (19)

iOS Human Interface Guidelines (HCI)
iOS Human Interface Guidelines (HCI)iOS Human Interface Guidelines (HCI)
iOS Human Interface Guidelines (HCI)
 
Why the iPad UI matters, And how it differs from the Tablet PC, but also from...
Why the iPad UI matters, And how it differs from the Tablet PC, but also from...Why the iPad UI matters, And how it differs from the Tablet PC, but also from...
Why the iPad UI matters, And how it differs from the Tablet PC, but also from...
 
Life Cycle of an iPhone App
Life Cycle of an iPhone AppLife Cycle of an iPhone App
Life Cycle of an iPhone App
 
iPhone Applications & Luxury Brands - Updated May 5, 2010
iPhone Applications & Luxury Brands - Updated May 5, 2010iPhone Applications & Luxury Brands - Updated May 5, 2010
iPhone Applications & Luxury Brands - Updated May 5, 2010
 
Programing for the iPhone
Programing for the iPhonePrograming for the iPhone
Programing for the iPhone
 
不能承受的感動 - iOS App實機測試
不能承受的感動 - iOS App實機測試不能承受的感動 - iOS App實機測試
不能承受的感動 - iOS App實機測試
 
Designing better user interfaces
Designing better user interfacesDesigning better user interfaces
Designing better user interfaces
 
iPhone Development Overview
iPhone Development OverviewiPhone Development Overview
iPhone Development Overview
 
Best Practice iPhone SDK App Design
Best Practice iPhone SDK App DesignBest Practice iPhone SDK App Design
Best Practice iPhone SDK App Design
 
iPad/iPhone - UI Design Resources
iPad/iPhone - UI Design ResourcesiPad/iPhone - UI Design Resources
iPad/iPhone - UI Design Resources
 
How to market your app
How to market your appHow to market your app
How to market your app
 
iPhone - Human Interface Guidelines
iPhone - Human Interface GuidelinesiPhone - Human Interface Guidelines
iPhone - Human Interface Guidelines
 
iPhone Introduction
iPhone IntroductioniPhone Introduction
iPhone Introduction
 
10 Design Commandments for Mobile App Developers
10 Design Commandments for Mobile App Developers10 Design Commandments for Mobile App Developers
10 Design Commandments for Mobile App Developers
 
如何變成iOS App開發魔法師
如何變成iOS App開發魔法師如何變成iOS App開發魔法師
如何變成iOS App開發魔法師
 
7 User Experience Lessons from the iPhone (Introducing UX)
7 User Experience Lessons from the iPhone (Introducing UX)7 User Experience Lessons from the iPhone (Introducing UX)
7 User Experience Lessons from the iPhone (Introducing UX)
 
Smart phones
Smart phonesSmart phones
Smart phones
 
iPhone transfer software
iPhone transfer softwareiPhone transfer software
iPhone transfer software
 
Android 4.0 UI Design Tips
Android 4.0 UI Design TipsAndroid 4.0 UI Design Tips
Android 4.0 UI Design Tips
 

Ähnlich wie Top Tips for Android UIs - Getting the Magic on Tablets

Android Development with Flash Builder Burrito
Android Development with Flash Builder BurritoAndroid Development with Flash Builder Burrito
Android Development with Flash Builder BurritoJeff Bollinger
 
Android Application Development - Level 1
Android Application Development - Level 1Android Application Development - Level 1
Android Application Development - Level 1Isham Rashik
 
Android Workshop 2013
Android Workshop 2013Android Workshop 2013
Android Workshop 2013Junda Ong
 
Android Bootcamp Tanzania:understanding ui in_android
Android Bootcamp Tanzania:understanding ui in_androidAndroid Bootcamp Tanzania:understanding ui in_android
Android Bootcamp Tanzania:understanding ui in_androidDenis Minja
 
Android app material design from dev's perspective
Android app material design from dev's perspectiveAndroid app material design from dev's perspective
Android app material design from dev's perspectiveDeSmart Agile Software House
 
Android animations
Android animationsAndroid animations
Android animationsKumar
 
Beginning Native Android Apps
Beginning Native Android AppsBeginning Native Android Apps
Beginning Native Android AppsGil Irizarry
 
Embracing the Lollipop
Embracing the LollipopEmbracing the Lollipop
Embracing the LollipopSonja Kesic
 
MOPCON 2014 - Best software architecture in app development
MOPCON 2014 - Best software architecture in app developmentMOPCON 2014 - Best software architecture in app development
MOPCON 2014 - Best software architecture in app developmentanistar sung
 
Marakana Android User Interface
Marakana Android User InterfaceMarakana Android User Interface
Marakana Android User InterfaceMarko Gargenta
 
01 09 - graphical user interface - basic widgets
01  09 - graphical user interface - basic widgets01  09 - graphical user interface - basic widgets
01 09 - graphical user interface - basic widgetsSiva Kumar reddy Vasipally
 
Build UI of the Future with React 360
Build UI of the Future with React 360Build UI of the Future with React 360
Build UI of the Future with React 360RapidValue
 
viWave Study Group - Introduction to Google Android Development - Chapter 23 ...
viWave Study Group - Introduction to Google Android Development - Chapter 23 ...viWave Study Group - Introduction to Google Android Development - Chapter 23 ...
viWave Study Group - Introduction to Google Android Development - Chapter 23 ...Ted Chien
 

Ähnlich wie Top Tips for Android UIs - Getting the Magic on Tablets (20)

Designing Apps for the Motorola XOOM
Designing Apps for the Motorola XOOM Designing Apps for the Motorola XOOM
Designing Apps for the Motorola XOOM
 
Ap quiz app
Ap quiz appAp quiz app
Ap quiz app
 
Android Development with Flash Builder Burrito
Android Development with Flash Builder BurritoAndroid Development with Flash Builder Burrito
Android Development with Flash Builder Burrito
 
Supercharge your ui
Supercharge your uiSupercharge your ui
Supercharge your ui
 
Android Application Development - Level 1
Android Application Development - Level 1Android Application Development - Level 1
Android Application Development - Level 1
 
Hello world ios v1
Hello world ios v1Hello world ios v1
Hello world ios v1
 
Android Workshop 2013
Android Workshop 2013Android Workshop 2013
Android Workshop 2013
 
Android Bootcamp Tanzania:understanding ui in_android
Android Bootcamp Tanzania:understanding ui in_androidAndroid Bootcamp Tanzania:understanding ui in_android
Android Bootcamp Tanzania:understanding ui in_android
 
Android app material design from dev's perspective
Android app material design from dev's perspectiveAndroid app material design from dev's perspective
Android app material design from dev's perspective
 
Android animations
Android animationsAndroid animations
Android animations
 
Android 3
Android 3Android 3
Android 3
 
Beginning Native Android Apps
Beginning Native Android AppsBeginning Native Android Apps
Beginning Native Android Apps
 
Embracing the Lollipop
Embracing the LollipopEmbracing the Lollipop
Embracing the Lollipop
 
Getting the Magic on Android Tablets
Getting the Magic on Android TabletsGetting the Magic on Android Tablets
Getting the Magic on Android Tablets
 
Android view animation in android-chapter18
Android view animation in android-chapter18Android view animation in android-chapter18
Android view animation in android-chapter18
 
MOPCON 2014 - Best software architecture in app development
MOPCON 2014 - Best software architecture in app developmentMOPCON 2014 - Best software architecture in app development
MOPCON 2014 - Best software architecture in app development
 
Marakana Android User Interface
Marakana Android User InterfaceMarakana Android User Interface
Marakana Android User Interface
 
01 09 - graphical user interface - basic widgets
01  09 - graphical user interface - basic widgets01  09 - graphical user interface - basic widgets
01 09 - graphical user interface - basic widgets
 
Build UI of the Future with React 360
Build UI of the Future with React 360Build UI of the Future with React 360
Build UI of the Future with React 360
 
viWave Study Group - Introduction to Google Android Development - Chapter 23 ...
viWave Study Group - Introduction to Google Android Development - Chapter 23 ...viWave Study Group - Introduction to Google Android Development - Chapter 23 ...
viWave Study Group - Introduction to Google Android Development - Chapter 23 ...
 

Mehr von Motorola Mobility - MOTODEV

HTML5 vs Native Android: Smart Enterprises for the Future
HTML5 vs Native Android: Smart Enterprises for the FutureHTML5 vs Native Android: Smart Enterprises for the Future
HTML5 vs Native Android: Smart Enterprises for the FutureMotorola Mobility - MOTODEV
 
Getting Your App Discovered: Android Market & Beyond
Getting Your App Discovered: Android Market & BeyondGetting Your App Discovered: Android Market & Beyond
Getting Your App Discovered: Android Market & BeyondMotorola Mobility - MOTODEV
 
Gráficos cada vez más rápidos. Cómo usar NDK y RenderScript
Gráficos cada vez más rápidos. Cómo usar NDK y RenderScript Gráficos cada vez más rápidos. Cómo usar NDK y RenderScript
Gráficos cada vez más rápidos. Cómo usar NDK y RenderScript Motorola Mobility - MOTODEV
 
Consejos principales para Android UI Cómo alcanzar la magia en los tablets
Consejos principales para Android UI Cómo alcanzar la magia en los tabletsConsejos principales para Android UI Cómo alcanzar la magia en los tablets
Consejos principales para Android UI Cómo alcanzar la magia en los tabletsMotorola Mobility - MOTODEV
 
Cómo agregar calidad a sus aplicaciones mediante pruebas
Cómo agregar calidad a sus aplicaciones mediante pruebas Cómo agregar calidad a sus aplicaciones mediante pruebas
Cómo agregar calidad a sus aplicaciones mediante pruebas Motorola Mobility - MOTODEV
 
Cómo aprovechar Webtop Cómo HTML5 mejora la experiencia del usuario
Cómo aprovechar Webtop Cómo HTML5 mejora la experiencia del usuarioCómo aprovechar Webtop Cómo HTML5 mejora la experiencia del usuario
Cómo aprovechar Webtop Cómo HTML5 mejora la experiencia del usuarioMotorola Mobility - MOTODEV
 
Gráficos cada vez mais rápidos utilização de NDK e Renderscript
Gráficos cada vez mais rápidos utilização de NDK e RenderscriptGráficos cada vez mais rápidos utilização de NDK e Renderscript
Gráficos cada vez mais rápidos utilização de NDK e RenderscriptMotorola Mobility - MOTODEV
 
Como integrar qualidade aos seus aplicativos através de testes
Como integrar qualidade aos seus aplicativos através de testesComo integrar qualidade aos seus aplicativos através de testes
Como integrar qualidade aos seus aplicativos através de testesMotorola Mobility - MOTODEV
 

Mehr von Motorola Mobility - MOTODEV (20)

HTML5 vs Native Android: Smart Enterprises for the Future
HTML5 vs Native Android: Smart Enterprises for the FutureHTML5 vs Native Android: Smart Enterprises for the Future
HTML5 vs Native Android: Smart Enterprises for the Future
 
The Enterprise Dilemma: Native vs. Web
The Enterprise Dilemma: Native vs. WebThe Enterprise Dilemma: Native vs. Web
The Enterprise Dilemma: Native vs. Web
 
Kill the Laptop!
Kill the Laptop!Kill the Laptop!
Kill the Laptop!
 
MOTODEV App Validator
MOTODEV App ValidatorMOTODEV App Validator
MOTODEV App Validator
 
Beautifully Usable, Multiple Screens Too
Beautifully Usable, Multiple Screens TooBeautifully Usable, Multiple Screens Too
Beautifully Usable, Multiple Screens Too
 
Getting Your App Discovered: Android Market & Beyond
Getting Your App Discovered: Android Market & BeyondGetting Your App Discovered: Android Market & Beyond
Getting Your App Discovered: Android Market & Beyond
 
Introducing Fragments
Introducing FragmentsIntroducing Fragments
Introducing Fragments
 
Taking Advantage of Webtop
Taking Advantage of WebtopTaking Advantage of Webtop
Taking Advantage of Webtop
 
Building Quality Into Your Apps Through Testing
Building Quality Into Your Apps Through TestingBuilding Quality Into Your Apps Through Testing
Building Quality Into Your Apps Through Testing
 
Top Tips for Android UIs
Top Tips for Android UIsTop Tips for Android UIs
Top Tips for Android UIs
 
Designing Apps for Motorla Xoom Tablet
Designing Apps for Motorla Xoom TabletDesigning Apps for Motorla Xoom Tablet
Designing Apps for Motorla Xoom Tablet
 
Diseñando aplicaciones para el Motorola XOOM
Diseñando aplicaciones para el Motorola XOOM Diseñando aplicaciones para el Motorola XOOM
Diseñando aplicaciones para el Motorola XOOM
 
Presentación de los fragmentos
Presentación de los fragmentos Presentación de los fragmentos
Presentación de los fragmentos
 
Gráficos cada vez más rápidos. Cómo usar NDK y RenderScript
Gráficos cada vez más rápidos. Cómo usar NDK y RenderScript Gráficos cada vez más rápidos. Cómo usar NDK y RenderScript
Gráficos cada vez más rápidos. Cómo usar NDK y RenderScript
 
Consejos principales para Android UI Cómo alcanzar la magia en los tablets
Consejos principales para Android UI Cómo alcanzar la magia en los tabletsConsejos principales para Android UI Cómo alcanzar la magia en los tablets
Consejos principales para Android UI Cómo alcanzar la magia en los tablets
 
Cómo agregar calidad a sus aplicaciones mediante pruebas
Cómo agregar calidad a sus aplicaciones mediante pruebas Cómo agregar calidad a sus aplicaciones mediante pruebas
Cómo agregar calidad a sus aplicaciones mediante pruebas
 
Cómo aprovechar Webtop Cómo HTML5 mejora la experiencia del usuario
Cómo aprovechar Webtop Cómo HTML5 mejora la experiencia del usuarioCómo aprovechar Webtop Cómo HTML5 mejora la experiencia del usuario
Cómo aprovechar Webtop Cómo HTML5 mejora la experiencia del usuario
 
Principais dicas para UIs do Android
Principais dicas para UIs do AndroidPrincipais dicas para UIs do Android
Principais dicas para UIs do Android
 
Gráficos cada vez mais rápidos utilização de NDK e Renderscript
Gráficos cada vez mais rápidos utilização de NDK e RenderscriptGráficos cada vez mais rápidos utilização de NDK e Renderscript
Gráficos cada vez mais rápidos utilização de NDK e Renderscript
 
Como integrar qualidade aos seus aplicativos através de testes
Como integrar qualidade aos seus aplicativos através de testesComo integrar qualidade aos seus aplicativos através de testes
Como integrar qualidade aos seus aplicativos através de testes
 

Kürzlich hochgeladen

Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfhans926745
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 

Kürzlich hochgeladen (20)

Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 

Top Tips for Android UIs - Getting the Magic on Tablets

  • 1. Suzanne Alexandra Android Technology Evangelist Motorola Mobility Top Tips for Android UIs Getting the Magic on Tablets MOTOROLA and the Stylized M Logo are trademarks or registered trademarks of Motorola Trademark Holdings, LLC. All other trademarks are the property of their respective owners. © 2011 Motorola Mobility, Inc. All rights reserved.
  • 2. @suzalex developer.motorola.com Presentation Title Version 1.0 02.24.09
  • 4. We're in a whole new place. Bring the right stuff aboard. Space Chips http://moto.ly/spacechips
  • 5. Get the magic 01 KEEP ERGONOMICS THOUGHTFUL 02 ENGAGE THE SENSES 03 USE COOL AESTHETICS 04 MAKE IT OBVIOUS
  • 6. Get the magic 01 KEEP ERGONOMICS THOUGHTFUL Landscape layouts Rich notifications Text sizes 02 ENGAGE THE SENSES Images Touchability 03 USE COOL AESTHETICS Themes, themes, themes 04 MAKE IT OBVIOUS Action bars Fragments Drag and drop
  • 7. Assume your users are using landscape.
  • 8. Landscape layouts Landscape often needs specialized layouts, on any device
  • 9. Landscape layouts Look what happens on the tablet
  • 10. Landscape layouts What went wrong? alignParentLeft alignParentRight Nothing in the center Small image
  • 11. Landscape layouts Design for screen size AND orientation
  • 12. Landscape layouts The winning layout centerHorizontal="true" <RelativeLayout> layout_alignLeft layout_alignRight
  • 13. Landscape layouts Optimize the user experience for wide screens
  • 14. Landscape layouts Avoid the wide, wide ocean effect
  • 15. Text sizes Small text (like images) probably won't work
  • 16. Text sizes Best practices Scale with sp 18 sp and up Be sure text is readable to real users
  • 17. Rich notifications A key benefit of Android over other mobile platforms Your app notification
  • 18. Rich notifications Examples of when to use rich notifications When new content arrives When media is playing
  • 19. Rich notifications On Honeycomb, two notification displays Tray Popup
  • 20. Rich notifications Use the Notification.Builder class Notification.Builder builder = new Notification.Builder( this ); Like AlertDialog.Builder
  • 21. Rich notifications Build the notification you want builder.setSmallIcon(R.drawable.icon) .setContentTitle(title) .setContentText(text) .setContentIntent(pintent) // A pending intent .setLargeIcon(myBitmap) ;
  • 22. Rich notifications Visual coding setLargeIcon() setSmallIcon() setContentTitle() setContentText()
  • 23. Rich notifications Get some magic - create a clickable button RemoteViews layout = new RemoteViews( getPackageName(), R.layout.notification); layout.setTextViewText(R.id.notification_title, getString(R.string.app_name)); layout.setOnClickPendingIntent(R.id.notification_button, getDialogPendingIntent("Tapped") ); builder.setContent(layout);
  • 24. Rich notifications Strategy for backward compatibility private static boolean isHoneycomb = android.os.Build.VERSION.SDK_INT > 10; if (!isHoneycomb) // start one activity intent else // start another
  • 25. Get the magic 01 KEEP ERGONOMICS THOUGHTFUL 02 ENGAGE THE SENSES Images Touchability 03 USE COOL AESTHETICS 04 MAKE IT OBVIOUS
  • 26. Vision trumps all other senses. Brain Rules Dr. John Medina
  • 28. Images Screens for different devices need different image sizes
  • 29. Images Choose an image strategy One set of images and let Android autoscale? Custom resource sets for different sizes and densities? Target the most commonly used density? Retrieve images dynamically at runtime and scale for the device?
  • 30. Images Memory vs file size – an example Autoscaling 32 MB memory 324 KB size Image sets 23 MB memory 728 KB size
  • 31. Autoscaling uses memory. Custom image sets increase file size.
  • 32. Images Sample large images at runtime to save memory 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);
  • 33. Images Where to place images and icons Default, auto-scaled High resolution icons Prescaled for density Match 3.0 styling
  • 35. Touchability Make sure all targets are tappable
  • 36. Touchability Make sure all targets are tappable public View getView( int position, View convertView, ViewGroup parent) { ImageView i = new ImageView(mContext); i.setImageResource(mImageIds[position]); i.setLayoutParams(new Gallery.LayoutParams( 300, 200)); i.setScaleType(ImageView.ScaleType.FIT_XY); i.setBackgroundResource( mGalleryItemBackground); return i; }
  • 37. Touchability Watch how images transfer across devices 160 dpi – medium 16:9 aspect ratio
  • 38. Get the magic 01 KEEP ERGONOMICS THOUGHTFUL 02 ENGAGE THE SENSES 03 USE COOL AESTHETICS Themes, themes, themes 04 MAKE IT OBVIOUS
  • 39. Themes Fit in with the device, or stand out
  • 40. Themes Honeycomb has two new holographic themes Theme.Holo Theme.Holo.Light
  • 41. Themes But they require hardware acceleration <application android:icon="@drawable/icon" android:label="@string/app_name" android:hardwareAccelerated="true" > Only available with Honeycomb
  • 42. Themes But you might be targeting multiple Android versions <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="11" />
  • 43. Themes Create multiple themes for Android versions <style … parent= "@android:style/Theme"> <style … parent= "@android:style/Theme.Holo">
  • 44. Be sure all API calls you use work for all API versions you support.
  • 45. Get the magic 01 KEEP ERGONOMICS THOUGHTFUL 02 ENGAGE THE SENSES 03 USE COOL AESTHETICS 04 MAKE IT OBVIOUS Action bars Fragments Drag and drop
  • 46. Action bars Make your app features readily available App icon Drop-down dialog Action view Action items
  • 47. Action bars Visual coding <item android:showAsAction="true" … > onCreateOptionsMenu() android:actionLayout onOptionsItemSelected() android:actionViewClass
  • 48. Action bars Step 1 – Target API level 11 <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="11" />
  • 49. Action bars Step 2 – Place menu items on action bar <item android:id="@+id/favorite" android:title="@string/favorite" android:icon="@drawable/ic_menu_star" android:showAsAction="ifRoom" />
  • 50. Action bars Step 3 - Handle options selection as usual @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.favorite: // do something return true; … }
  • 51. Action bars On XOOM and smartphone
  • 52. Action bars Get some magic, style it <style name="MyTheme" parent="android:style/Theme.Holo" > <item name="android:actionBarStyle"> @style/ActionBar</item> </style> <style name="ActionBar" parent="android:style/Widget.Holo.ActionBar"> <item name="android:background"> @drawable/my_background</item> </style>
  • 53. Action bars Get some magic, add a dialog Use AlertDialog.Builder Create a custom dialog in XML Use a DialogFragment
  • 54. Action bars But do Honeycomb stuff only on Honeycomb private static boolean isHoneycomb = android.os.Build.VERSION.SDK_INT > 10; if (isHoneycomb) { // build custom dialog here }
  • 55. Fragments Use to display more content and features, more fluidly
  • 56. Fragments You can use many patterns Most common
  • 57. Fragments The starting fragment layout is the same across orientations
  • 58. Fragments But you can show or hide views
  • 59. Fragments In your main activity, find your fragments Fragment gridFrag = getFragmentManager(). findFragmentById(R.id.photogrid); Fragment photoFrag = getFragmentManager(). findFragmentById(R.id.the_frag);
  • 60. Fragments Check the orientation and adjust the views private boolean photoInline = false; photoInline = (photoFrag != null && getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE); if (photoInline) { // do something } else if ( photoFrag != null ) { getView().setVisibility(View.GONE); }
  • 61. Fragments Even better Animated transition
  • 62. Fragments Get some magic – animate fragment display #1 <set> <objectAnimator xmlns:android= http://schemas.android.com/apk/res/android android:propertyName="x" android:valueType="floatType" android:valueFrom="-1280" android:valueTo="0" android:duration="500" /> </set>
  • 63. Fragments Get some magic – animate fragment display #2 FragmentTransaction ft = getFragmentManager().beginTransaction(); ft.setCustomAnimations( R.anim.slide_in_left, R.anim.slide_out_right ); DetailsFragment newFrag =DetailsFragment.newInstance(); ft.replace(R.id.details_fragment_container, newFrag, "detailFragment"); ft.commit();
  • 64. Drag and drop Creates direct, immediate physical engagement
  • 65. Drag and drop Has a number of event states ACTION_DRAG_STARTED ACTION_DRAG_ENTERED
  • 66. Drag and drop Has a number of event states ACTION_DROP ACTION_DRAG_ENDED
  • 67. Drag and drop Watch how it works across fragments
  • 68. Drag and drop Getting started #1 public boolean onDrag(View v, DragEvent event) { if (event.getAction() == DragEvent.ACTION_DRAG_STARTED){ border = v.getBackground(); v.setBackgroundDrawable(redBorder); } else if (event.getAction() == DragEvent.ACTION_DRAG_ENTERED){ isWithin = true; } else if (event.getAction() == DragEvent.ACTION_DRAG_EXITED){ isWithin = false; } continued …
  • 69. Drag and drop Getting started #2 else if (event.getAction() == DragEvent.ACTION_DROP){ if (isWithin){ View view = (View) event.getLocalState(); ViewGroup owner = (ViewGroup) view.getParent(); owner.removeView(view); LinearLayout container = (LinearLayout) v; container.addView(view); } } else if (event.getAction() == DragEvent.ACTION_DRAG_ENDED){ v.setBackgroundDrawable(noBorder); } return true; }
  • 70. Questions? @suzalex @motodev developer.motorola.com
  • 72. LEGAL LICENSE NOTICES Except where noted, sample source code written by Motorola Mobility Inc. and provided to you is licensed as described below. Copyright © 2010-2011, 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 offered under other licenses.
 Apache 2.0 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. Creative Commons 3.0 Attribution License Portions of this presentation are reproduced from work created and shared by Google (http://code.google.com/policies.html) and used according to terms described in the Creative Commons 3.0 Attribution License (http://creativecommons.org/licenses/by/3.0/).