Android用xml將ImageView加上陰影(drop shadow)
參考這篇SO的解答 custom-imageview-with-drop-shadow
但我用的是另一個9 patch,從另個DroidDudes:Easy drop shadow:找到的
將上圖複製到drawable下後,利用xml code配合padding將圖片加上陰影:
之後可微調 paddingRight 和 paddingBottom 兩項數值,取得最佳的效果
但我用的是另一個9 patch,從另個DroidDudes:Easy drop shadow:找到的
將上圖複製到drawable下後,利用xml code配合padding將圖片加上陰影:
<ImageView
android:id="@+id/ImageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="fitXY"
android:adjustViewBounds="true"
android:paddingRight="8px"
android:paddingBottom="9px"
android:background="@drawable/dropshadow"
android:src="@drawable/my_image" />
之後可微調 paddingRight 和 paddingBottom 兩項數值,取得最佳的效果
| 沒有陰影 | android:paddingRight="9px" android:paddingBottom="9px" |
android:paddingRight="14px" android:paddingBottom="12px" |
![]() |




Comments
Post a Comment