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

Tweetcaster Lets You Tell Tweeters to Zip It

With Tivo, I almost never watch live TV, delaying even big games and season finales so that I can skip the ads. But since I always have one eye on Twitter, occasionally a surprise is spoiled when I see someone tweet who’s watching in real time. Handmark’s Twitter client Tweetcaster has added a feature that will help solve that problem.

News and Rumors

Search More than 5 Million Song Lyrics with musiXmatch

Wanna settle that debate of what Michael Stipe is actually singing in “It’s the End of the World as we Know It (And I Feel Fine)?  The next time you

News and Rumors

1 year free of Netflix, Milk Music with purchase of Samsung Galaxy S5, Note 4, Tab S, or 4k TV

For the few of you who held off to get a new device until after the new year, you’re in luck as Samsung is rewarding you with a year subscription


  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