Friday, 23 September 2011

Fixing the dojox.mobile.TabBar to the bottom of the mobile screen

The Dojox.mobile API provides some great features, functions and themes to quickly code up web services for mobile platforms, and have them appear in a familiar, native style to the device, with intuitive and easy to use menus, navigation, and form features.

There is, however, one quirky issue (with dojo 1.6 at least) which took me a few minutes to figure out, and so I thought I'd write up a quick post to help anyone else who is having trouble getting the TabBar to "stick" to the bottom of the screen, whilst the rest of the content happily scrolls.


Using the dojox.mobile API, you will most likely have built up your panes with a collection of dojox.mobile.View, and dojox.mobile.ScrollableView elements, and these have a different affect on where the dojox.mobile.TabBar appears.

If you have used dojox.mobile.ScrollableView, this makes the TabBar float over the top of an otherwise scrolling main-content. You need to add a style of "margin-top: -49px;" to the TabBar node to raise it into the viewport, but it will then always be visible, like so:

dojox.mobile.ScrollableView


To navigate, on mobile devices you use a "stroking" finger gesture, and on computers/compat devices, you must use an equivalent click-and-drag movement. This can have shortfalls in some environments, such as Blackberrys, where there is no touch screen, or click-and-drag functionality.

If you opted for dojox.mobile.View then the dojox.mobile.TabBar will appear at the bottom of the page, and the user will have to scroll down to the bottom access it. A scrollbar is displayed on the right hand side to facilitate this movement.

dojox.mobile.View 

This is the most universal and reliable format for cross-platform services, because you can still invoke a scroll motion using a touch-screen swipe, but pointing and scrolling devices can still also be used for easy navigation.

You can mix and match your view types, even within the same navigational flow, and each pane will act accordingly as above, of course, if you do switch between them, it is going to give an inconsistent user experience.

3 comments:

  1. Can you send the dojox.mobile.View code?

    ReplyDelete
    Replies
    1. Well, dojox.mobile.View isn't really sendable as an individual file/concept..? It's a widget in the Dojo Toolkit.

      You can download the Dojo Toolkit here:
      http://dojotoolkit.org/

      and View.js would be located at:
      \dojo-release-1.7.1\dojox\mobile
      within the archive.

      ScrollableView is also in there, and documentation on both panel types is available at:
      http://dojotoolkit.org/reference-guide/dojox/mobile/View.html

      Delete
  2. Amazing Article! Your informations like a charm. I have read 3 books on Android app development , nowhere I can find these instructions. Lots of thanks for this excellent tutorial. You saved my time hours. THANKS. Do you know about any Top mobile App Development companies in Dubai?

    ReplyDelete