logo

Android: Google+ Style Page Swiping

The Google+ app on Android has a nice view-paging system that's becoming an increasingly-common UI feature on mobile apps:

image

See the light grey bar about 1/3 down in the shot above? See the arrow pointing upward to "All Circles"? That's the current page. Swiping to the right will take me (leftward) to the "Nearby" page and conversely, swiping left takes me to "Incoming". Unless you've used it you won't get just how nice it feels when used.

When I first saw this interface in use I immediately wanted to know how I could add it to my own apps. However, I'd already gotten to know the Android SDK well enough to know it wasn't one of the standard design elements, so I just assumed it wasn't something I - a noob to Android - could do.

Turns out though that it's not that hard at all. Hey, if I can do it, so can you!

Here are some screenshots of a stock-tracking app I've been working on where I've managed to add a set of pages which scroll horizontally between stocks in the portfolio.

imageimageimage

Each of the three screenshots above works through the three stocks listed in the database in alphabetical order. When you get to either end then there's nothing listed on the far side of the "indicator" bar. Obviously it works with >3 stocks, but you get the drift.

How Did I Do It?

As it turns out there's something called the "compatibility package" for Android devs, which is an add-on to the standard SDK and has some extra goodies in it. One of these extras is the ViewPager class, which is what lets you swipe horizontally between views.

When you take the ViewPager class and add a ViewPagerIndicator you quickly start to see how the Google+ design came to be. You can then go further and style it and do with it as you will.

The same class used also lets you use "circle indicators" like those used in the BBC News Android app:

image

Reminds me that I did the same thing using Flex back in May. Nice to know how to do it natively too as it's a handy design pattern that can fit nicely in to most situations.

Comments

    • avatar
    • Chris C
    • Tue 13 Sep 2011 01:39 PM

    Jake, that's pretty interesting. How you thought about playing around with Xcode and doing any iPhone/iPad development yet?

      • avatar
      • Jake Howlett
      • Tue 13 Sep 2011 01:46 PM

      It's on my radar and I will do at some point. It all comes down to a lack of the most precious of commodities: time...

    1. I don't know about Jake, but I know why I don't work with Xcode -- Apple refuses to let their SDK be installed on anything other than a Mac. :P If they dropped that ridiculous requirement, I'd be able to.

  1. Looking forward to your next release!

Your Comments

Name:
E-mail:
(optional)
Website:
(optional)
Comment:


About This Page

Written by Jake Howlett on Tue 13 Sep 2011

Share This Page

# ( ) '

Comments

The most recent comments added:

Skip to the comments or add your own.

You can subscribe to an individual RSS feed of comments on this entry.

Let's Get Social


About This Website

CodeStore is all about web development. Concentrating on Lotus Domino, ASP.NET, Flex, SharePoint and all things internet.

Your host is Jake Howlett who runs his own web development company called Rockall Design and is always on the lookout for new and interesting work to do.

You can find me on Twitter and on Linked In.

Read more about this site »

More Content