Top Banner
Action Bar – AB & ActionBarSherlock - ABS
35

Action bar & ActionBarSherlock

May 19, 2015

Download

Technology

Zahid Ali Shah

Presentation @ Coeus-Solutions Lahore - Feb 2013
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Action bar & ActionBarSherlock

Action Bar – AB&

ActionBarSherlock - ABS

Page 2: Action bar & ActionBarSherlock

ContentAction BarGeneral Organization Action BarSplit Action BarContextual Action BarActionBarSherlock

RequirementsCode SnippetsSummaryQuestions

Page 3: Action bar & ActionBarSherlock

Action barThe action bar is a window feature that

identify the application and user location, and provides user actions and navigation modes

Action bar offers users a consistent interface across application.

Introduced in API level 11 (Android 3.0 Honeycomb)

Page 4: Action bar & ActionBarSherlock

Backward CompatibilityActionBar class is not available in older

versions of Android (< 3.0).

Alternate: ActionBarSherlock (ABS) library helps creating Action bar, back up to android 2.x

Other option: Action Bar Compatibility (see sample app in API Demos)

Page 5: Action bar & ActionBarSherlock

General Organization

1. App Icon2. View Control3. Action Buttons4. Action Overflow

Page 6: Action bar & ActionBarSherlock

1. App Icon Establishes app's identity

 Displays Up caret to the left of the app icon, to navigate up the hierarchy.

Page 7: Action bar & ActionBarSherlock

2. View controlIf your app displays data in different views,

this segment of the action bar allows users to switch views.i. Drop-down menusii. Tab controlsiii. Custom Navigation

App title or longer branding information can also use this space.

Page 8: Action bar & ActionBarSherlock

3. Action ButtonsAction buttons on the action bar surface

your app's most important activities.

 Actions that don't fit in the action bar are moved automatically to the action overflow.

Action buttons used throughout the Gmail application

Page 9: Action bar & ActionBarSherlock

4. Action overflowAction overflow provides access to frequently

used actions. The overflow icon only appears on phones

that have no menu hardware keys. Phones with menu keys display the action

overflow when the user presses the key.

Action overflow is pinned to the right side.

Page 10: Action bar & ActionBarSherlock

Split Action Bars There are three possible locations to split

action bar content.

1. Main action bar2. Top bar3. Bottom bar

Note: Available on Android 4.0 (API level 14) and higher, for native AB, or use ABS for backward compatibility

Page 11: Action bar & ActionBarSherlock
Page 12: Action bar & ActionBarSherlock

AB on Different Screen Sizes

Gmail App

Page 13: Action bar & ActionBarSherlock

How many items will fit in the main action bar?

Action buttons in the main action bar may not occupy more than 50% of the bar's width.

Action buttons on bottom action bars can use the entire width.

Page 14: Action bar & ActionBarSherlock

How many actions will fit in the main action bar?

Density-independent pixels (dp) determine the number of items in action bar.

smaller than 360 dp = 2 icons360-499 dp = 3 icons500-599 dp = 4 icons600 dp and larger = 5 icons

Page 15: Action bar & ActionBarSherlock

Contextual Action Bar

A contextual action bar (CAB) is a temporary action bar.

It overlays the app's action bar for the duration of a particular sub-task.

CABs are most typically used for tasks that

involve acting on selected data or text.

Page 16: Action bar & ActionBarSherlock

Contextual Action Bar

Like normal Action Bar, CAB also support split action bar.

ActionMode represents a contextual mode (or CAB) of the user interface.

Dismiss the CAB via i. Navigation bar's Back buttonii. CAB's checkmark button

Page 17: Action bar & ActionBarSherlock

Contextual Action Bar

Page 18: Action bar & ActionBarSherlock

ActionBarSherlock (ABS)

ActionBarSherlock is a standalone library.

It allows developer to develop apps with action bar on Android API level 2.x and up.

Current version: 4.2.0 — 08-10-2012

Developed by : Jake Wharton

Page 19: Action bar & ActionBarSherlock

ActionBarSherlock (ABS)

The library will automatically use native Action Bar implementation on Android 4.0 or above.

On Android 3.x (Honeycomb), app will prefer ABS over native Action Bar.

Page 20: Action bar & ActionBarSherlock

ABS Requirements

It is required that both ABS library and your project are compiled with Android 4.0 or newer.

It is also required that you are compiling with JDK 1.6 in both, your editor and build systems.

Page 21: Action bar & ActionBarSherlock

ABS Theme RequirementsThe ABS library provides three core themes.

Theme.SherlockTheme.Sherlock.LightTheme.Sherlock.Light.DarkActionBar

One of above theme is must for all activities having action bar.

Custom Theme

Page 22: Action bar & ActionBarSherlock

Native AB VS ABS

Native AB classes ABS library classes

ActivityFragmentActivityFragmentListFragmentListActivityDialogFragment

SherlockActivitySherlockFragmentActi

vitySherlockFragmentSherlockListFragmentSherlockListActivitySherlockDialogFragme

nt

Page 23: Action bar & ActionBarSherlock

ABS Common ImportsEnsure that you are using these types

where appropriate

com.actionbarsherlock.app.ActionBarcom.actionbarsherlock.view.Menucom.actionbarsherlock.view.MenuItemcom.actionbarsherlock.view.MenuInflater

Note: ABS contain same classes that are named

same as their native counterparts

Page 24: Action bar & ActionBarSherlock

ABS and Proguard

Add the following lines in proguard.cfg, to ensure proper functionality of the library:

-keep class android.support.v4.app.** { *; }-keep interface android.support.v4.app.**

{ *; }-keep class com.actionbarsherlock.** { *; }-keep interface com.actionbarsherlock.** { *; }-keep attributes *Annotation*

Page 25: Action bar & ActionBarSherlock

Action Bar – Menu xmlCreate XML file in /res/menu/my_menu

Page 26: Action bar & ActionBarSherlock

Action Bar

Page 27: Action bar & ActionBarSherlock

Action Bar

Page 28: Action bar & ActionBarSherlock

Menu Item

Page 29: Action bar & ActionBarSherlock

Split Action Bar

Update AndroidManifest.xml

Page 30: Action bar & ActionBarSherlock

Tabs

Page 31: Action bar & ActionBarSherlock

ActionMode (CAB)

Page 32: Action bar & ActionBarSherlock
Page 33: Action bar & ActionBarSherlock

What else ?Action Providers i.e.

Settings Share Action

Provider

Navigation Mode

ProgressIndeterminate

ProgressHorizontal Progress

Bar

Search

Overlay

Static Attachment No need to extend

SherlockActivity etc Implement

OnCreateOptionsMenuListener

Page 34: Action bar & ActionBarSherlock

Summary

Native Action bar - Introduced in Android API 11 (Android 3.0 Honeycomb)

ActionBarSherlock support API 2.x and above.

ABS library will automatically use native Action Bar implementation on Android 4.0 or above.

Be careful while importing classes, ABS have same class names as native AB.

Split Action barContextual Action bar

Page 35: Action bar & ActionBarSherlock

Questions