Flipping Your Views

Let’s face it: phones are small.

Even if you have a phone with excellent screen resolution, the physical screen size is still rarely over 3″x5″, since most people want phones that can fit in a pocket, purse, pouch, or poncho.

This means your Android activities can only display so much stuff at one time without individual widgets or text getting too small to be easily read. There are any number of ways to handle this:

  • You could break the one activity into several…but this can get cumbersome
  • You can use ScrollView to allow users to scroll through a longer activity…but this may or may not be easy for the user depending on the device (e.g., a haptic interface using a swipe for scrolling assumes there’s a place clear in the UI for them to actually swipe without accidentally toggling a button or something)
  • You can use TabView, as described in the previous post…but you are locked into a particular presentation pattern (e.g., tabs)
  • You can use ViewFlipper and work out a UI pattern that’s right for you

Not surprisingly, today, we’re going to look at the latter option.

ViewFlipper inherits from FrameLayout, just like we used to describe the innards of a TabView in that previous post. However, initially, it just shows the first child view. It is up to you to arrange for the views to flip, either manually by user interaction, or automatically via a timer.

For example, here is a layout for a simple activity using a Button and a ViewFlipper:

[sourcecode language=”xml”]


About author

AndroidGuys 4641 posts

Founded on November 5, 2007, we've enjoyed bringing you the latest in Android news and rumors. Updated daily, we strive to deliver reviews, opinions, and updates on all things related to Android.

You might also like

News and Rumors

Android Playstation Emulator Released!

One of the nice things about having one of the current gen Android handsets is the ability to run different video game emulators.  I have really enjoyed playing old school

News and Rumors

Android L likely to mean Lemon Meringue Pie – Android LMP

Ever since Android L hit the scene everyone has been wondering what the ‘L’ stood for, and today it looks like there’s evidence as to just what Android L stood

News and Rumors

Best Buy’s Rocketfish Tablet Expected to Run Android

Best Buy recently announced a strategic relationship with Clearwire, which should see the retail giant providing 4G mobile broadband service under the Best Buy Connect brand. As part of the deal, Best Buy will offer a one stop shop and support for mobile broadband devices to take advantage of the speedy 4G network. One such device is likely to be the newly-twitter-leaked Rocketfish tablet.