2014-02-26 57 views
1

我正在使用9貼片爲投影盒產生投影。如果圖像寬度爲280dp(20dp離開禁區邊緣),我得到一個不錯的陰影(@ 315度):當圖像接近邊緣時,9貼片投影會消失

enter image description here

不過,如果我使圖像觸摸框邊緣,右側邊緣的陰影幾乎消失:

enter image description here

這裏是我的佈局:

<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="match_parent" 
    android:layout_height="300dp" 
    android:background="@drawable/dropshadow"> 
<ImageView 
    android:id="@+id/frontimage" 
    android:layout_width="match_parent" 
    android:layout_height="130dp" 
    android:layout_alignParentTop="true" 
    android:scaleType="center" 
/> 
... 
</RelativeLayout> 

這裏的9補丁我使用的是:

enter image description here

有誰知道爲什麼發生這種情況?

謝謝!

回答

4

將頂部和左側黑色邊框縮小爲1 px(可拉伸區域)。

像這樣:

enter image description here

或者,您也可以減少一些像素的右側和底部的黑色邊框(引進一些填充)。

像這樣:

enter image description here

或者,您可以添加一些空白(透明)空間(假設每邊4像素)的圖像之間(包括陰影)和黑色邊框。
這將添加一些填充。

OR

您可以添加一些填充到你的RelativeLayout

+0

感謝。其實我試圖沒有任何填充,並希望圖像觸摸邊緣。我已經嘗試了您的建議,但圖像接觸邊緣時圖像附近的陰影仍然很暗淡。 – Kar

+1

因此,我建議只在影子附近添加一些填充(底部和右側)。這應該給一些空間(不要讓陰影真的碰到窗口邊緣)。另一個嘗試的想法是將陰影變暗一點。和(可能更好?)放大陰影尺寸。 –

+0

你知道爲什麼圖像靠近邊緣會影響陰影清晰度嗎? – Kar