From 463d225e6fa1a1d52c3ddf9804e9467b2020da96 Mon Sep 17 00:00:00 2001 From: marcosod Date: Wed, 24 Aug 2016 09:51:55 -0500 Subject: [PATCH] Update Label.java fade out label background --- .../main/java/com/github/clans/fab/Label.java | 47 ++++++++++--------- 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/library/src/main/java/com/github/clans/fab/Label.java b/library/src/main/java/com/github/clans/fab/Label.java index 7d689cb..82de249 100755 --- a/library/src/main/java/com/github/clans/fab/Label.java +++ b/library/src/main/java/com/github/clans/fab/Label.java @@ -31,8 +31,8 @@ public class Label extends TextView { private static final Xfermode PORTER_DUFF_CLEAR = new PorterDuffXfermode(PorterDuff.Mode.CLEAR); private int mShadowRadius; - private int mShadowXOffset; - private int mShadowYOffset; + // private int mShadowXOffset; + // private int mShadowYOffset; private int mShadowColor; private Drawable mBackgroundDrawable; private boolean mShowShadow = true; @@ -60,35 +60,35 @@ public Label(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } - @Override + /* @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, heightMeasureSpec); setMeasuredDimension(calculateMeasuredWidth(), calculateMeasuredHeight()); - } - + }*/ +/* private int calculateMeasuredWidth() { if (mRawWidth == 0) { mRawWidth = getMeasuredWidth(); } return getMeasuredWidth() + calculateShadowWidth(); - } + }*/ - private int calculateMeasuredHeight() { + /* private int calculateMeasuredHeight() { if (mRawHeight == 0) { mRawHeight = getMeasuredHeight(); } return getMeasuredHeight() + calculateShadowHeight(); - } + }*/ - int calculateShadowWidth() { + /* int calculateShadowWidth() { return mShowShadow ? (mShadowRadius + Math.abs(mShadowXOffset)) : 0; - } + }*/ - int calculateShadowHeight() { + /* int calculateShadowHeight() { return mShowShadow ? (mShadowRadius + Math.abs(mShadowYOffset)) : 0; - } + }*/ - void updateBackground() { + /* void updateBackground() { LayerDrawable layerDrawable; if (mShowShadow) { layerDrawable = new LayerDrawable(new Drawable[]{ @@ -116,7 +116,7 @@ void updateBackground() { setBackgroundCompat(layerDrawable); } - +*/ @TargetApi(Build.VERSION_CODES.LOLLIPOP) private Drawable createFillDrawable() { StateListDrawable drawable = new StateListDrawable(); @@ -163,8 +163,8 @@ private Drawable createRectDrawable(int color) { private void setShadow(FloatingActionButton fab) { mShadowColor = fab.getShadowColor(); mShadowRadius = fab.getShadowRadius(); - mShadowXOffset = fab.getShadowXOffset(); - mShadowYOffset = fab.getShadowYOffset(); + // mShadowXOffset = fab.getShadowXOffset(); + // mShadowYOffset = fab.getShadowYOffset(); mShowShadow = fab.hasShadow(); } @@ -334,6 +334,11 @@ private Shadow() { this.init(); } + @Override + public void draw(Canvas canvas) { + + } + private void init() { setLayerType(LAYER_TYPE_SOFTWARE, null); mPaint.setStyle(Paint.Style.FILL); @@ -342,15 +347,15 @@ private void init() { mErase.setXfermode(PORTER_DUFF_CLEAR); if (!isInEditMode()) { - mPaint.setShadowLayer(mShadowRadius, mShadowXOffset, mShadowYOffset, mShadowColor); + // mPaint.setShadowLayer(mShadowRadius, mShadowXOffset, mShadowYOffset, mShadowColor); } } - @Override + /* @Override public void draw(Canvas canvas) { RectF shadowRect = new RectF( - mShadowRadius + Math.abs(mShadowXOffset), - mShadowRadius + Math.abs(mShadowYOffset), + mShadowRadius + Math.abs(mShadowXOffset), + mShadowRadius + Math.abs(mShadowYOffset), mRawWidth, mRawHeight ); @@ -358,7 +363,7 @@ public void draw(Canvas canvas) { canvas.drawRoundRect(shadowRect, mCornerRadius, mCornerRadius, mPaint); canvas.drawRoundRect(shadowRect, mCornerRadius, mCornerRadius, mErase); } - +*/ @Override public void setAlpha(int alpha) {