https://github.com/yingLanNull/ShadowImageView
阴影效果的实现
public void setShadowLayer(float radius, float dx, float dy, int shadowColor)
阴影的颜色
阴影效果设置两次
ShadowImageViewif (((ImageView) view).getDrawable() instanceof ColorDrawable) { rgb = ((ColorDrawable) ((ImageView) view).getDrawable()).getColor(); shadowPaint.setShadowLayer(40, 0, 28, getDarkerColor(rgb)); } else if (((ImageView) view).getDrawable() instanceof BitmapDrawable) { bitmap = ((BitmapDrawable) ((ImageView) view).getDrawable()).getBitmap(); Palette.Swatch mSwatch = Palette.from(bitmap).generate().getDominantSwatch(); if (null != mSwatch) { rgb = mSwatch.getRgb(); } else { rgb = Color.parseColor("#8D8D8D"); } shadowPaint.setShadowLayer(radius, 0, shadowDimen, getDarkerColor(rgb)); Bitmap bitmapT = Bitmap.createBitmap(bitmap, 0, bitmap.getHeight() / 4 * 3, bitmap.getWidth(), bitmap.getHeight() / 4); if (null != Palette.from(bitmapT).generate().getDominantSwatch()) { rgb = Palette.from(bitmapT).generate().getDominantSwatch().getRgb(); shadowPaint.setShadowLayer(radius, 0, shadowDimen, rgb); } } else { rgb = Color.parseColor("#8D8D8D"); shadowPaint.setShadowLayer(radius, 0, shadowDimen, getDarkerColor(rgb)); }