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.
You might also like
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
“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
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