How would I go about implementing a shadow like the one you see under the title bar? I know this can be done (see for example the app "Andlytics", where this effect shows on the bottom as well).
My best guess is that it's a banner image used as the backg开发者_运维百科round for the layout. But maybe there is a better way?
I looked through the images in the SDK's data/res folder and I found what is probably being used: title_bar_shadow.9.png
. Errr, can't attach it here, but you should be able to find it in your android-sdk-location/platforms/android-N/data/res/drawable-hdpi/
folder.
I'm guessing it is probably achieved by using a 9-patch with a gradient on the top edge and corners as the layout background. I don't know of any better way, but this should be pretty simple to implement.
Take a look at this question: Custom ImageView with drop shadow
Or we could use a gradient - and Android seems to be going that way. In later versions of the platform SDK code, the title bar image is replaced by action_bar_divider.xml.
The divide is nothing but:
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:startColor="#ffe1e2e4"
android:endColor="#ff95979a"
android:angle="270" />
</shape>
You can use it in an image view just below your title bar.
精彩评论