I'm looking for a way to overlay a drop shadow onto a ScrollView like this:
My intention is to have another layout above and outside the ScrollView (the green one) that stays at the top while scrolling the content of the ScrollView. The ScrollView should have a drop shadow overlay at the top which appears to be from the layout above.
Since I want the content of the ScrollView to scroll into the drop shadow, that shadow must not be part of the layout above, otherwise the drop shadow would stay seperated from the scrolling contents below.
Any ideas how I can bring that drop shadow to life? I found android:foreground but then read that it wouldn't work on ScrollViews.
Ok, found a solution to do this. This is what I did:
To have a drop shadow image overlay on the ScrollView, I put the ScrollView inside a FrameLayout and applied the drop shadow drawable to the FrameLayout via android:foreground.
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:foreground="@drawable/drop_shadow_bitmap"
android:foregroundGravity="top|fill_horizontal" >
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top" >
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With