One From the Stack: Finding Out How It’s Done

The One From the Stack series will highlight some interesting questions and answers from StackOverflow’s #android tag, a fine place to get your Android application development questions answered.

Today’s one from the Stack is from a developer trying to figure out how to attain a look and feel similar to one that is already in Android. In this case, the poster is looking for the gray box behind the Done and Revert buttons in the Edit Contact activity in the built-in “Dialtacts” application.

If you poke through the source code, you would eventually stumble upon this layout file, showing that the button bar has a style=”@android:style/ButtonBar”. Tugging on that thread via Google Code Search will give you this styles.xml snippet, indicating that the background for that style is @android:drawable/bottom_bar.

At this point, you can turn to your local SDK. All resources are stored in $SDK/platforms/$PLATFORM/data/res, where $SDK is wherever you installed your SDK and $PLATFORM is the specific Android version you are interested in (e.g., android-2.1). If you go in there, you will see that bottom_bar refers to a pair of PNG files, one in data/res/drawable-hdpi and one in data/res/drawable-mdpi.

You might be tempted to just plop the same style or background image reference in your own code. While simple, this leads to somewhat fragile code, as you are now dependent upon things that are not truly part of the SDK. Part of the reason for making all these resources available to you in your SDK installation is so you can copy them into your project, so you are now independent of any changes Android makes to its names or looks of these images.

Note that the answer I provided on the question itself is a bit off. I thought that hierarchyviewer would be another possibility, rather than poking through the source code. Unfortunately, I didn’t think that all of the way through — hierarchyviewer does not report background resource values.

About author

AndroidGuys 4625 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

AnTuTu reports most popular smartphones of 2014

AnTuTu, one of the most trusted and stable benchmarking app recently released a report on the top most popular smartphones of 2014. What can be a better way to bid

News and Rumors

Gameloft promises support for Intel architecture

“We are thrilled to optimize our upcoming games for new Android platforms running Intel architecture and once again expand our game catalogue to new high-performance smartphones and tablets,” states Gonzague De

News and Rumors

Google Maps adds Waze incidents in 46 new countries & territories

Google and Waze today announced that incident reporting has come to the Google Maps app for 46 new countries and territories. Now you’ll have a clearer idea as to where


  1. jharana
    August 10, 13:53 Reply

    These are some more highly beneficial services from the android towards strengthening the visual programming open source platform. Thanks for the information.Projector Screen Paint

  2. Harold
    October 25, 11:30 Reply

    Pretty technical, wasn’t able to fully follow it all the way through…

Leave a Reply