0

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 background for the layout. But maybe there is a better way?

dmon
  • 30,048
  • 8
  • 87
  • 96
Jason
  • 4,034
  • 4
  • 40
  • 62

4 Answers4

2

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.

Gabriel Negut
  • 13,860
  • 4
  • 38
  • 45
2

Take a look at this question: Custom ImageView with drop shadow

Community
  • 1
  • 1
inazaruk
  • 74,247
  • 24
  • 188
  • 156
2

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.

dmon
  • 30,048
  • 8
  • 87
  • 96
1

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.

codeFood
  • 1,241
  • 16
  • 16