1 / 18

Introduction to tablet optimization

Introduction to tablet optimization. Indy Android Developers - Oct 15, 2013. Overview. Why Optimize for Tablets? Using Fragments Using the Action Bar Available Resources. Why Optimize for tablets?.

lewist
Download Presentation

Introduction to tablet optimization

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Introduction totablet optimization • Indy Android Developers - Oct 15, 2013

  2. Overview • Why Optimize for Tablets? • Using Fragments • Using the Action Bar • Available Resources

  3. Why Optimize for tablets? • Most apps that are designed with flexible layouts will work perfectly fine on tablets by utilizing scaling. • The main reason to further optimize your Android app for tablets is to greater utilize the available space on bigger screens, and present a better user interface over the automatically scaled interface.

  4. Using Fragments • With API 11 Android introduced a new set of framework APIs called Fragments • Fragments allow you to break up your UI elements into individual classes and then organize those fragments dynamically in an activity • Fragments are available in the Support Library for older Android versions

  5. Using Fragments - Overview • Single-pane and Multi-pane Layouts • Multiple Fragments, One Activity • Multiple Fragments, Multiple Activities • Using Multiple Fragment Layouts • Guidelines for Fragments • Layout Selectors

  6. Single-Pane and Multi-pane Layouts • There are two distinct ways to optimize your app using fragments for multiple screen sizes. • The first is Multiple Fragments, One Activity • The second is Multiple Fragments, Multiple Activities

  7. Multiple Fragments, One Activity • You create one main activity for your app UI, and then switch fragments in and out of that activity based on the screen size. • Fragments must be created programmatically instead of through XML because any fragment created in XML cannot be removed from the layout. • The Action Bar must be updated when switching out Fragments in the activity • You have to manually manage the back stack using the FragmentManager

  8. Multiple fragments, multiple activities • You create separate layouts for small screens and large screens. • On large screens, you put multiple fragments in your layouts • On smaller screens, you put single fragments in your layouts • Fragments can be defined in XML

  9. Multiple fragments, multiple activities • You still use one main activity, but the correct layout is automatically determined by Android based on layout selectors. • When switching screens, you load a new activity instead of swapping out fragments • This is the suggested method in the Android Best Practices for Supporting Tablets and Handsets

  10. using multiple fragment layouts • When using multiple layouts, you need to determine if the fragment is available before trying to reference it. • FragmentManager.findFragmentById(FRAGMENT_ID) • If the Fragment exists, interact with it • If the Fragment does not exist, start a new Activity that contains it

  11. Guidelines for Fragments • Do not manipulate one fragment directly from another • Define callbacks in your fragments that the activity can implement to listen for events • Keep all code that concerns content in a fragment inside that fragment

  12. Layout Selectors • Small screens would use the default selector: res/layouts/main.xml • Larger screens would use the larger selector: res/layouts-large/main.xml • API13 and above support more fine grained layout selectors

  13. Using the action bar • The ActionBar will automatically resize when the screen size changes • If you are using a standard ActionBar and handling ActionBar buttons correctly, you can let Android handle your navigation changes for you on different screen sizes

  14. Using the action bar - overview • Using the Overflow Menu • Using the Split Action Bar • Supporting Older Android Versions

  15. using the overflow menu • When defining your ActionBar buttons, you have a setting called “showAsAction” • If you set this option to “ifRoom”, the button will only show up if there is enough room on the screen to show it • If you are using ActionBar button titles, you can also use “ifRoom|withText” to hide those titles when on a smaller screen • You can still use “always” for really important buttons, but you shouldn’t use more than two of these

  16. using the split action bar • If you are using API14 or higher, you can enable the split ActionBar to handle overflow items • The split ActionBar shows up at the bottom of the screen on smaller devices • To enable, you set the “uiOptions” attribute to “splitActionBarWhenNarrow” to your <activity> or <application> elements in your manifest file • This option is ignored on older devices and should therefore be safe to use

  17. supporting older android versions • The ActionBar was first introduced in API 11 which is Android 3.0 • To use the ActionBar in older versions of Android, you should use the Support Library • You can use third-party ActionBar implementations such as ActionBarSherlock to provide a easier fallback on older Android versions

  18. available resources • http://developer.android.com/guide/practices/tablets-and-handsets.html - Supporting Tablets and Handsets • http://developer.android.com/guide/practices/screens_support.html - Supporting Multiple Screens • http://android-developers.blogspot.com/2012/11/designing-for-tablets-were-here-to-help.html - Designing for Tablets • http://developer.android.com/distribute/googleplay/quality/tablet.html - Tablet App Quality Checklist • http://developer.android.com/guide/topics/ui/actionbar.html - Action Bar

More Related