2012-07-15 68 views
7

我正在尋找一種方式來覆蓋陰影到滾動型是這樣的:如何將投影覆蓋到滾動視圖上?

drop shadow example

我的本意是具有以上且停留在了滾動(綠色的)之外的另一個佈局同時滾動ScrollView的內容。 ScrollView的頂部應該有一個陰影覆蓋層,看起來像上面的佈局。

因爲我想了滾動的內容滾動到陰影,那黑影一定不能高於佈局的一部分,否則,陰影會保持從下面的滾動內容分隔。

任何想法,我可以如何將該陰影帶入生活? 我找到了android:foreground,但後來發現它不適用於ScrollViews。

+0

我覺得沒有人會注意到當它的部分佈局在上面。它仍然可能看起來像內容被陰影覆蓋。另一件我能想到的事情,將是一個Framelayout。所以你可以將它覆蓋到滾動視圖上 – Ahmad 2012-07-16 01:09:04

回答

10

好的,找到了解決方案來做到這一點。這是我做的:

要在ScrollView上有一個陰影圖像疊加層,我將ScrollView放在一個FrameLayout中,並通過android:foreground將可拖動的陰影應用到FrameLayout。

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