-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
wujingchao
committed
Apr 18, 2015
1 parent
11743ed
commit 4ed5753
Showing
6 changed files
with
176 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
multi-card-menu/src/main/java/net/wujingchao/android/view/DarkFrameLayout.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package net.wujingchao.android.view; | ||
|
||
import android.content.Context; | ||
import android.graphics.Canvas; | ||
import android.graphics.Color; | ||
import android.graphics.Paint; | ||
import android.support.annotation.NonNull; | ||
import android.util.AttributeSet; | ||
import android.widget.FrameLayout; | ||
|
||
/** | ||
* @author wujingchao 2015-04-18 email:[email protected] | ||
*/ | ||
class DarkFrameLayout extends FrameLayout { | ||
|
||
public final static int MAX_ALPHA = 0x7f; | ||
|
||
private Paint mFadePaint; | ||
|
||
private int alpha = 0x00; | ||
|
||
public DarkFrameLayout(Context context) { | ||
this(context, null); | ||
} | ||
|
||
public DarkFrameLayout(Context context, AttributeSet attrs) { | ||
this(context, attrs, 0); | ||
} | ||
|
||
|
||
public DarkFrameLayout(Context context, AttributeSet attrs, int defStyleAttr) { | ||
super(context, attrs, defStyleAttr); | ||
mFadePaint = new Paint(); | ||
} | ||
|
||
@Override | ||
protected void dispatchDraw(@NonNull Canvas canvas) { | ||
super.dispatchDraw(canvas); | ||
drawFade(canvas); | ||
} | ||
|
||
private void drawFade(Canvas canvas) { | ||
mFadePaint.setColor(Color.argb(alpha, 0, 0, 0)); | ||
canvas.drawRect(0, 0, getMeasuredWidth(), getHeight(), mFadePaint); | ||
} | ||
|
||
public void fade(boolean fade) { | ||
this.alpha = fade ? 0x8f : 0x00; | ||
invalidate(); | ||
} | ||
|
||
public void fade(int alpha) { | ||
this.alpha = alpha; | ||
invalidate(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters