KeyguardUserSwitcherScrimpublic class KeyguardUserSwitcherScrim extends android.graphics.drawable.Drawable implements View.OnLayoutChangeListenerGradient background for the user switcher on Keyguard. |
Fields Summary |
---|
private static final float | OUTER_EXTENT | private static final float | INNER_EXTENT | private int | mDarkColor | private int | mTop | private int | mAlpha | private android.graphics.Paint | mRadialGradientPaint | private int | mLayoutWidth |
Constructors Summary |
---|
public KeyguardUserSwitcherScrim(android.view.View host)
host.addOnLayoutChangeListener(this);
mDarkColor = host.getResources().getColor(
R.color.keyguard_user_switcher_background_gradient_color);
|
Methods Summary |
---|
public void | draw(android.graphics.Canvas canvas)
boolean isLtr = getLayoutDirection() == LayoutDirection.LTR;
Rect bounds = getBounds();
float width = bounds.width() * OUTER_EXTENT;
float height = (mTop + bounds.height()) * OUTER_EXTENT;
canvas.translate(0, -mTop);
canvas.scale(1, height / width);
canvas.drawRect(isLtr ? bounds.right - width : 0, 0,
isLtr ? bounds.right : bounds.left + width, width, mRadialGradientPaint);
| public int | getAlpha()
return mAlpha;
| public int | getOpacity()
return PixelFormat.TRANSLUCENT;
| public void | onLayoutChange(android.view.View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom)
if (left != oldLeft || top != oldTop || right != oldRight || bottom != oldBottom) {
mLayoutWidth = right - left;
mTop = top;
updatePaint();
}
| public void | setAlpha(int alpha)
mAlpha = alpha;
updatePaint();
invalidateSelf();
| public void | setColorFilter(android.graphics.ColorFilter cf)
| private void | updatePaint()
if (mLayoutWidth == 0) {
return;
}
float radius = mLayoutWidth * OUTER_EXTENT;
boolean isLtr = getLayoutDirection() == LayoutDirection.LTR;
mRadialGradientPaint.setShader(
new RadialGradient(isLtr ? mLayoutWidth : 0, 0, radius,
new int[] { Color.argb(
(int) (Color.alpha(mDarkColor) * mAlpha / 255f), 0, 0, 0),
Color.TRANSPARENT },
new float[] { Math.max(0f, mLayoutWidth * INNER_EXTENT / radius), 1f },
Shader.TileMode.CLAMP));
|
|