Creating a Button Bar in Android

In application development we often talk about the importance of consistency, in particular with respect to interfaces.  In mobile application this is even more important.

In Android we often see a standard button bar as shown below.image

This is a common technique that can provide a very flexible consistent layout.  The core XML for your layout file is shown below.image

This is one of the advantages of the RelativeLayout, the ability the precisely control where elements appear.  In this case, we use a LinearLayout to stack the RelativeLayout beneath another LinearLayout.  The RelativeLayout is then configured to anchor itself to the base of the screen.

I am currently using this technique in an application to provide a consistent look for your application.  It gives you flexibility as well.  You can use the RelativeLayout to add additional buttons to the bar.  You could even apply additional layout controls to the RelativeLayout to add more buttons.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s