本文整理汇总了Java中android.graphics.Paint.setAlpha方法的典型用法代码示例。如果您正苦于以下问题:Java Paint.setAlpha方法的具体用法?Java Paint.setAlpha怎么用?Java Paint.setAlpha使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.graphics.Paint
的用法示例。
在下文中一共展示了Paint.setAlpha方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: BorderedText
import android.graphics.Paint; //导入方法依赖的package包/类
/**
* Create a bordered text object with the specified interior and exterior colors, text size and
* alignment.
*
* @param interiorColor the interior text color
* @param exteriorColor the exterior text color
* @param textSize text size in pixels
*/
public BorderedText(final int interiorColor, final int exteriorColor, final float textSize) {
interiorPaint = new Paint();
interiorPaint.setTextSize(textSize);
interiorPaint.setColor(interiorColor);
interiorPaint.setStyle(Style.FILL);
interiorPaint.setAntiAlias(false);
interiorPaint.setAlpha(255);
exteriorPaint = new Paint();
exteriorPaint.setTextSize(textSize);
exteriorPaint.setColor(exteriorColor);
exteriorPaint.setStyle(Style.FILL_AND_STROKE);
exteriorPaint.setStrokeWidth(textSize / 8);
exteriorPaint.setAntiAlias(false);
exteriorPaint.setAlpha(255);
this.textSize = textSize;
}
示例2: draw
import android.graphics.Paint; //导入方法依赖的package包/类
@Override
public void draw(Canvas canvas, Paint paint) {
float circleSpacing=4;
float radius=(getWidth()-circleSpacing*4)/6;
float x = getWidth()/ 2-(radius*2+circleSpacing);
float y = getWidth()/ 2-(radius*2+circleSpacing);
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
canvas.save();
float translateX=x+(radius*2)*j+circleSpacing*j;
float translateY=y+(radius*2)*i+circleSpacing*i;
canvas.translate(translateX, translateY);
canvas.scale(scaleFloats[3 * i + j], scaleFloats[3 * i + j]);
paint.setAlpha(alphas[3 * i + j]);
canvas.drawCircle(0, 0, radius, paint);
canvas.restore();
}
}
}
示例3: onDraw
import android.graphics.Paint; //导入方法依赖的package包/类
/**
* First try to draw whatever image was given to this view. If that doesn't exist, try to draw
* a geometric pattern based on the palette that was given to us. If we haven't had a colour
* assigned to us (using {@link #setColour(int)}) then clear the view by filling it with white.
*/
@Override
protected void onDraw(Canvas canvas) {
if (getDrawable() != null) {
super.onDraw(canvas);
} else if (trianglePaints != null) {
for (Paint paint : trianglePaints) {
paint.setAlpha(currentAlpha);
}
canvas.drawColor(baseColour);
for (int i = 0; i < triangles.length; i++) {
canvas.drawPath(triangles[i], trianglePaints[i]);
}
} else {
canvas.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR);
}
}
示例4: setColors
import android.graphics.Paint; //导入方法依赖的package包/类
public void setColors(int mainColor, int frameColor, int chargeColor) {
if (mBattery != null) {
try {
Object drawable = getDrawable();
final int[] colors = (int[]) XposedHelpers.getObjectField(drawable, "mColors");
colors[colors.length - 1] = mainColor;
if (Utils.isLineageOs()) {
Drawable frameDrawable = (Drawable) XposedHelpers.getObjectField(drawable, "mFrameDrawable");
frameDrawable.setAlpha(mFrameAlpha);
frameDrawable.setTint(frameColor);
Paint paint = (Paint) XposedHelpers.getObjectField(drawable, "mTextAndBoltPaint");
paint.setColor(chargeColor);
} else {
final Paint framePaint = (Paint) XposedHelpers.getObjectField(drawable, "mFramePaint");
framePaint.setColor(frameColor);
framePaint.setAlpha(mFrameAlpha);
XposedHelpers.setIntField(drawable, "mChargeColor", chargeColor);
}
XposedHelpers.setIntField(drawable, "mIconTint", mainColor);
} catch (Throwable t) {
XposedBridge.log(t);
}
}
}
示例5: init
import android.graphics.Paint; //导入方法依赖的package包/类
private void init(LineConfig config) {
bgPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
bgPaint.setColor(Color.TRANSPARENT);
paint = new Paint(Paint.ANTI_ALIAS_FLAG);
paint.setStrokeWidth(config.getThick());
paint.setColor(config.getColor());
paint.setAlpha(config.getAlpha());
}
示例6: SingleLineItemDecoration
import android.graphics.Paint; //导入方法依赖的package包/类
public SingleLineItemDecoration(int divider_height,int divider_color) {
lineHeight = divider_height;
lineColor = divider_color;
paint = new Paint();
paint.setColor(lineColor);
paint.setAlpha(240);
}
示例7: drawLanguageOnSpacebar
import android.graphics.Paint; //导入方法依赖的package包/类
private void drawLanguageOnSpacebar(final Key key, final Canvas canvas, final Paint paint) {
final Keyboard keyboard = getKeyboard();
if (keyboard == null) {
return;
}
final int width = key.getWidth();
final int height = key.getHeight();
paint.setTextAlign(Align.CENTER);
paint.setTypeface(Typeface.DEFAULT);
paint.setTextSize(mLanguageOnSpacebarTextSize);
final String language = layoutLanguageOnSpacebar(paint, keyboard.mId.mSubtype, width);
// Draw language text with shadow
final float descent = paint.descent();
final float textHeight = -paint.ascent() + descent;
final float baseline = height / 2 + textHeight / 2;
if (mLanguageOnSpacebarTextShadowRadius > 0.0f) {
paint.setShadowLayer(mLanguageOnSpacebarTextShadowRadius, 0, 0,
mLanguageOnSpacebarTextShadowColor);
} else {
paint.clearShadowLayer();
}
paint.setColor(mLanguageOnSpacebarTextColor);
paint.setAlpha(mLanguageOnSpacebarAnimAlpha);
canvas.drawText(language, width / 2, baseline - descent, paint);
paint.clearShadowLayer();
paint.setTextScaleX(1.0f);
}
示例8: init
import android.graphics.Paint; //导入方法依赖的package包/类
private void init() {
drawRoundRectRadius = dpToPx(5);
setScaleType(ImageView.ScaleType.FIT_XY);
clickableStroke = new Paint(Paint.ANTI_ALIAS_FLAG);
clickableStroke.setStrokeWidth(1f);
clickableStroke.setStyle(Paint.Style.STROKE);
clickableStroke.setStrokeCap(Paint.Cap.ROUND);
clickableStroke.setColor(Color.BLUE);
clickFill = new Paint(Paint.ANTI_ALIAS_FLAG);
clickFill.setStyle(Paint.Style.FILL_AND_STROKE);
clickFill.setStrokeCap(Paint.Cap.ROUND);
clickFill.setColor(Color.BLUE);
clickFill.setAlpha(70);
clickStroke = new Paint(Paint.ANTI_ALIAS_FLAG);
clickStroke.setStyle(Paint.Style.STROKE);
clickStroke.setColor(Color.BLUE);
clickStroke.setStrokeWidth(2f);
clickStroke.setStrokeCap(Paint.Cap.ROUND);
warnFill = new Paint(Paint.ANTI_ALIAS_FLAG);
warnFill.setStyle(Paint.Style.FILL_AND_STROKE);
warnFill.setStrokeCap(Paint.Cap.ROUND);
warnFill.setColor(Color.YELLOW);
warnFill.setAlpha(70);
warnStroke = new Paint(Paint.ANTI_ALIAS_FLAG);
warnStroke.setStyle(Paint.Style.STROKE);
warnStroke.setColor(Color.YELLOW);
warnStroke.setStrokeWidth(2f);
warnStroke.setStrokeCap(Paint.Cap.ROUND);
setOnTouchListener(this);
gestureDetector = new GestureDetector(getContext(), new OnGestureListenerAnchor(this));
}
示例9: draw
import android.graphics.Paint; //导入方法依赖的package包/类
@Override
public void draw(Canvas canvas) {
super.draw(canvas);
int width = getWidth();
int height = getHeight();
rect = new Rect(width/12, height/5, width * 11 / 12, height *7 /10);
Paint p = new Paint();
p.setColor(Color.BLACK);
p.setStyle(Paint.Style.FILL);
p.setAlpha(76);
canvas.drawRect(0, 0, width, rect.top, p);
canvas.drawRect(0, rect.bottom, width, height, p);
canvas.drawRect(0, rect.top, rect.left, rect.bottom, p);
canvas.drawRect(rect.right, rect.top, width, rect.bottom, p);
p.setColor(Color.RED);
p.setAlpha(255);
p.setStrokeWidth(3);
int lineVerticalPos = rect.top + (rect.height() >> 1);
canvas.drawLine(rect.left + 10, lineVerticalPos, rect.right - 10, lineVerticalPos, p);
p.setColor(Color.WHITE);
p.setStrokeWidth(3);
float[] vertice = {rect.left, rect.top, rect.right, rect.top,
rect.right, rect.top, rect.right, rect.bottom,
rect.right, rect.bottom, rect.left, rect.bottom,
rect.left, rect.top, rect.left, rect.bottom};
canvas.drawLines(vertice, p);
p.setARGB(255, 255, 141, 22);
p.setStrokeWidth(5);
canvas.drawLine(rect.left, rect.top, rect.left + 40, rect.top, p);
canvas.drawLine(rect.right - 40, rect.top, rect.right, rect.top, p);
canvas.drawLine(rect.right, rect.top, rect.right, rect.top + 40, p);
canvas.drawLine(rect.right, rect.bottom - 40, rect.right, rect.bottom, p);
canvas.drawLine(rect.right - 40, rect.bottom, rect.right, rect.bottom, p);
canvas.drawLine(rect.left, rect.bottom, rect.left + 40, rect.bottom, p);
canvas.drawLine(rect.left, rect.bottom - 40, rect.left, rect.bottom, p);
canvas.drawLine(rect.left, rect.top, rect.left, rect.top + 40, p);
}
示例10: draw
import android.graphics.Paint; //导入方法依赖的package包/类
@Override
public void draw(Canvas canvas, Paint paint) {
float circleSpacing=4;
paint.setAlpha(alpha);
canvas.scale(scale,scale,getWidth()/2,getHeight()/2);
paint.setAlpha(alpha);
canvas.drawCircle(getWidth()/2,getHeight()/2,getWidth()/2-circleSpacing,paint);
}
示例11: draw
import android.graphics.Paint; //导入方法依赖的package包/类
@Override
public void draw(Canvas canvas, Paint paint) {
float radius=getWidth()/10;
for (int i = 0; i < 8; i++) {
canvas.save();
Point point=circleAt(getWidth(),getHeight(),getWidth()/2-radius,i*(Math.PI/4));
canvas.translate(point.x,point.y);
canvas.scale(scaleFloats[i],scaleFloats[i]);
paint.setAlpha(alphas[i]);
canvas.drawCircle(0,0,radius,paint);
canvas.restore();
}
}
示例12: createPillWithShadow
import android.graphics.Paint; //导入方法依赖的package包/类
public static Bitmap createPillWithShadow(int rectColor, int width, int height) {
float shadowRadius = height * 1f / 32;
float shadowYOffset = height * 1f / 16;
int radius = height / 2;
Canvas canvas = new Canvas();
Paint blurPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG);
blurPaint.setMaskFilter(new BlurMaskFilter(shadowRadius, Blur.NORMAL));
int centerX = Math.round(width / 2 + shadowRadius);
int centerY = Math.round(radius + shadowRadius + shadowYOffset);
int center = Math.max(centerX, centerY);
int size = center * 2;
Bitmap result = Bitmap.createBitmap(size, size, Config.ARGB_8888);
canvas.setBitmap(result);
int left = center - width / 2;
int top = center - height / 2;
int right = center + width / 2;
int bottom = center + height / 2;
// Draw ambient shadow, center aligned within size
blurPaint.setAlpha(AMBIENT_SHADOW_ALPHA);
canvas.drawRoundRect(left, top, right, bottom, radius, radius, blurPaint);
// Draw key shadow, bottom aligned within size
blurPaint.setAlpha(KEY_SHADOW_ALPHA);
canvas.drawRoundRect(left, top + shadowYOffset, right, bottom + shadowYOffset,
radius, radius, blurPaint);
// Draw the circle
Paint drawPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG);
drawPaint.setColor(rectColor);
canvas.drawRoundRect(left, top, right, bottom, radius, radius, drawPaint);
return result;
}
示例13: createOuterStrokeDrawable
import android.graphics.Paint; //导入方法依赖的package包/类
private Drawable createOuterStrokeDrawable(float strokeWidth) {
ShapeDrawable shapeDrawable = new ShapeDrawable(new OvalShape());
final Paint paint = shapeDrawable.getPaint();
paint.setAntiAlias(true);
paint.setStrokeWidth(strokeWidth);
paint.setStyle(Style.STROKE);
paint.setColor(Color.BLACK);
paint.setAlpha(opacityToAlpha(0.02f));
return shapeDrawable;
}
示例14: drawReferenceLine
import android.graphics.Paint; //导入方法依赖的package包/类
protected void drawReferenceLine(Canvas canvas) {
float canvasPadding = canvasWidth * canvasProjection.getPaddingFactor();
float maximumReferenceLineWidth = canvasWidth - (2 * canvasPadding);
float maximumReferenceDistance = (float) canvasProjection.getMetersFromCanvasUnits(maximumReferenceLineWidth);
float referenceDistance = DistanceUtil.getReasonableSmallerEvenDistance(maximumReferenceDistance);
float referenceLineWidth = (float) canvasProjection.getCanvasUnitsFromMeters(referenceDistance);
float referenceLinePadding = (canvasWidth - referenceLineWidth) / 2;
Paint legendPaint = new Paint(textPaint);
legendPaint.setAlpha(50);
legendPaint.setTextSize(pixelsPerDip * 12);
float referenceYOffset = canvasHeight - (pixelsPerDip * 16);
PointF referenceStartPoint = new PointF(referenceLinePadding, referenceYOffset);
PointF referenceEndPoint = new PointF(canvasWidth - referenceLinePadding, referenceYOffset);
// horizontal line
canvas.drawRect(
referenceStartPoint.x,
referenceStartPoint.y,
referenceEndPoint.x,
referenceEndPoint.y - pixelsPerDip,
legendPaint
);
// left vertical line
canvas.drawRect(
referenceStartPoint.x,
referenceStartPoint.y - (pixelsPerDip * 8),
referenceStartPoint.x + pixelsPerDip,
referenceStartPoint.y,
legendPaint
);
// right vertical line
canvas.drawRect(
referenceEndPoint.x,
referenceEndPoint.y - (pixelsPerDip * 8),
referenceEndPoint.x + pixelsPerDip,
referenceEndPoint.y,
legendPaint
);
// text
String referenceText = String.valueOf(Math.round(referenceDistance)) + " meters";
float referenceTextWidth = legendPaint.measureText(referenceText);
canvas.drawText(
referenceText,
(canvasWidth / 2) - (referenceTextWidth / 2),
referenceStartPoint.y - (pixelsPerDip * 4),
legendPaint
);
}
示例15: initView
import android.graphics.Paint; //导入方法依赖的package包/类
protected void initView() {
mMonthTitlePaint = new Paint();
mMonthTitlePaint.setFakeBoldText(true);
mMonthTitlePaint.setAntiAlias(true);
mMonthTitlePaint.setTextSize(MONTH_LABEL_TEXT_SIZE);
mMonthTitlePaint.setTypeface(Typeface.create(mMonthTitleTypeface, Typeface.BOLD));
mMonthTitlePaint.setColor(mDayTextColor);
mMonthTitlePaint.setTextAlign(Align.CENTER);
mMonthTitlePaint.setStyle(Style.FILL);
mMonthTitleBGPaint = new Paint();
mMonthTitleBGPaint.setFakeBoldText(true);
mMonthTitleBGPaint.setAntiAlias(true);
mMonthTitleBGPaint.setColor(mMonthTitleBGColor);
mMonthTitleBGPaint.setTextAlign(Align.CENTER);
mMonthTitleBGPaint.setStyle(Style.FILL);
mSelectedCirclePaint = new Paint();
mSelectedCirclePaint.setFakeBoldText(true);
mSelectedCirclePaint.setAntiAlias(true);
mSelectedCirclePaint.setColor(mTodayNumberColor);
mSelectedCirclePaint.setTextAlign(Align.CENTER);
mSelectedCirclePaint.setStyle(Style.FILL);
mSelectedCirclePaint.setAlpha(SELECTED_CIRCLE_ALPHA);
mMonthDayLabelPaint = new Paint();
mMonthDayLabelPaint.setAntiAlias(true);
mMonthDayLabelPaint.setTextSize(MONTH_DAY_LABEL_TEXT_SIZE);
mMonthDayLabelPaint.setColor(mDayTextColor);
mMonthDayLabelPaint.setTypeface(Typeface.create(mDayOfWeekTypeface, Typeface.NORMAL));
mMonthDayLabelPaint.setStyle(Style.FILL);
mMonthDayLabelPaint.setTextAlign(Align.CENTER);
mMonthDayLabelPaint.setFakeBoldText(true);
mMonthNumPaint = new Paint();
mMonthNumPaint.setAntiAlias(true);
mMonthNumPaint.setTextSize(MINI_DAY_NUMBER_TEXT_SIZE);
mMonthNumPaint.setStyle(Style.FILL);
mMonthNumPaint.setTextAlign(Align.CENTER);
mMonthNumPaint.setFakeBoldText(false);
}