Adding an option to change the shadow size

Change-Id: I8ec810c5cf06852771247af5f1d717f41079c4f5
This commit is contained in:
Sunny Goyal
2017-05-16 16:16:25 -07:00
parent 0dc1db4fee
commit 8b6ac00a1b
6 changed files with 11 additions and 16 deletions

View File

@@ -46,6 +46,7 @@ public class ShadowDrawable extends Drawable {
private final ShadowDrawableState mState;
@SuppressWarnings("unused")
public ShadowDrawable() {
this(new ShadowDrawableState());
}
@@ -98,17 +99,6 @@ public class ShadowDrawable extends Drawable {
return mState.mIntrinsicWidth;
}
/**
* Sets the color for the generated shadow
*/
public void setShadowColor(int color) {
if (mState.mShadowColor != color) {
mState.mShadowColor = color;
mState.mLastDrawnBitmap = null;
invalidateSelf();
}
}
private void regenerateBitmapCache() {
Bitmap bitmap = Bitmap.createBitmap(mState.mIntrinsicWidth, mState.mIntrinsicHeight,
Bitmap.Config.ARGB_8888);
@@ -154,7 +144,8 @@ public class ShadowDrawable extends Drawable {
}
mState.mShadowColor = a.getColor(
R.styleable.ShadowDrawable_android_shadowColor, Color.BLACK);
mState.mShadowSize = r.getDimensionPixelSize(R.dimen.drawable_shadow_size);
mState.mShadowSize = a.getDimensionPixelSize(
R.styleable.ShadowDrawable_android_elevation, 0);
mState.mIntrinsicHeight = d.getIntrinsicHeight() + 2 * mState.mShadowSize;
mState.mIntrinsicWidth = d.getIntrinsicWidth() + 2 * mState.mShadowSize;