本文整理匯總了Java中android.graphics.Canvas.saveLayerAlpha方法的典型用法代碼示例。如果您正苦於以下問題:Java Canvas.saveLayerAlpha方法的具體用法?Java Canvas.saveLayerAlpha怎麽用?Java Canvas.saveLayerAlpha使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.graphics.Canvas
的用法示例。
在下文中一共展示了Canvas.saveLayerAlpha方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: dispatchDraw
import android.graphics.Canvas; //導入方法依賴的package包/類
@Override
protected void dispatchDraw(Canvas canvas) {
super.dispatchDraw(canvas);
if (mAdapter == null || headers.isEmpty()) {
return;
}
for (View header : headers) {
int saveCount = canvas.save();
int top = (Integer)header.getTag();
canvas.translate(LocaleController.isRTL ? getWidth() - header.getWidth() : 0, top);
canvas.clipRect(0, 0, getWidth(), header.getMeasuredHeight());
if (top < 0) {
canvas.saveLayerAlpha(0, top, header.getWidth(), top + canvas.getHeight(), (int)(255 * (1.0f + (float)top / (float)header.getMeasuredHeight())), Canvas.HAS_ALPHA_LAYER_SAVE_FLAG);
}
header.draw(canvas);
canvas.restoreToCount(saveCount);
}
}
示例2: onDraw
import android.graphics.Canvas; //導入方法依賴的package包/類
@Override
protected void onDraw(Canvas canvas) {
canvas.saveLayerAlpha(mSaveLayerRectF, mAlpha, Canvas.MATRIX_SAVE_FLAG
| Canvas.CLIP_SAVE_FLAG | Canvas.HAS_ALPHA_LAYER_SAVE_FLAG
| Canvas.FULL_COLOR_LAYER_SAVE_FLAG | Canvas.CLIP_TO_LAYER_SAVE_FLAG);
// 繪製蒙板
canvas.drawBitmap(mMask, 0, mExtendOffsetY, mPaint);
mPaint.setXfermode(mXfermode);
// 繪製底部圖片
canvas.drawBitmap(mBottom, mRealPos, mExtendOffsetY, mPaint);
mPaint.setXfermode(null);
// 繪製邊框
canvas.drawBitmap(mFrame, 0, mExtendOffsetY, mPaint);
// 繪製按鈕
canvas.drawBitmap(mCurBtnPic, mRealPos, mExtendOffsetY, mPaint);
canvas.restore();
}
示例3: draw
import android.graphics.Canvas; //導入方法依賴的package包/類
@Override
public void draw(Canvas canvas) {
Rect bounds = getBounds();
canvas.saveLayerAlpha(bounds.left, bounds.top, bounds.right, bounds.bottom, mAlpha, Canvas.ALL_SAVE_FLAG);
super.draw(canvas);
canvas.restore();
}
示例4: draw
import android.graphics.Canvas; //導入方法依賴的package包/類
@Override
public void draw(Canvas canvas) {
Rect bounds = getBounds();
canvas.saveLayerAlpha(bounds.left, bounds.top, bounds.right, bounds.bottom, mAlpha, Canvas.ALL_SAVE_FLAG);
super.draw(canvas);
canvas.restore();
}
示例5: draw
import android.graphics.Canvas; //導入方法依賴的package包/類
@Override
public void draw(Context context, Canvas canvas) {
TextSticker textSticker = (TextSticker) sticker;
if (textSticker.textFile == null || textSticker.textFile.exists() == false) {
return;
}
TextMakingInfo textMakingInfo = textSticker.getTextMakeInfo(context);
int canvasWidth = canvas.getWidth();
int canvasHeight = canvas.getHeight();
float targetWidthDP = Util.px2dp(context, canvasWidth * widthRatio);
float textSize = targetWidthDP / textMakingInfo.getWidthTextRatio();
textMakingInfo.setTextSize(textSize);
Rect rect = new Rect();
textMakingInfo.getTextRect(context, rect);
float textRectWidth = rect.width();
float textRectHeight = rect.height();
Matrix matrix = new Matrix();
matrix.reset();
matrix.postTranslate((canvasWidth - textRectWidth) / 2, (canvasHeight - textRectHeight) / 2);
matrix.postRotate(angle, canvasWidth / 2, canvasHeight / 2);
matrix.postTranslate(canvasWidth / 2 * posX, canvasHeight / 2 * posY);
canvas.setMatrix(matrix);
canvas.saveLayerAlpha(0, 0, textRectWidth, textRectHeight, (int) (alpha * 255), Canvas.ALL_SAVE_FLAG);
textMakingInfo.draw(context, (int) textRectWidth, (int) textRectHeight, canvas);
canvas.restore();
matrix.reset();
canvas.setMatrix(matrix);
}
示例6: draw
import android.graphics.Canvas; //導入方法依賴的package包/類
@Override
public int draw(Canvas canvas) {
if (alpha == -1) {
return canvas.saveLayer(bounds, paint, saveFlags);
} else {
return canvas.saveLayerAlpha(bounds, alpha, saveFlags);
}
}
示例7: dispatchDraw
import android.graphics.Canvas; //導入方法依賴的package包/類
@Override
protected void dispatchDraw(Canvas canvas) {
super.dispatchDraw(canvas);
if (mDragState != IDLE) {
// draw the divider over the expanded item
if (mFirstExpPos != mSrcPos) {
drawDivider(mFirstExpPos, canvas);
}
if (mSecondExpPos != mFirstExpPos && mSecondExpPos != mSrcPos) {
drawDivider(mSecondExpPos, canvas);
}
}
if (mFloatView != null) {
// draw the float view over everything
final int w = mFloatView.getWidth();
final int h = mFloatView.getHeight();
int x = mFloatLoc.x;
int width = getWidth();
if (x < 0)
x = -x;
float alphaMod;
if (x < width) {
alphaMod = ((float) (width - x)) / ((float) width);
alphaMod *= alphaMod;
} else {
alphaMod = 0;
}
final int alpha = (int) (255f * mCurrFloatAlpha * alphaMod);
canvas.save();
// Log.d("mobeta", "clip rect bounds: " + canvas.getClipBounds());
canvas.translate(mFloatLoc.x, mFloatLoc.y);
canvas.clipRect(0, 0, w, h);
// Log.d("mobeta", "clip rect bounds: " + canvas.getClipBounds());
canvas.saveLayerAlpha(0, 0, w, h, alpha, Canvas.ALL_SAVE_FLAG);
mFloatView.draw(canvas);
canvas.restore();
canvas.restore();
}
}
示例8: onDraw
import android.graphics.Canvas; //導入方法依賴的package包/類
@Override
protected void onDraw(Canvas canvas) {
if (user == null && chat == null && encryptedChat == null) {
return;
}
if (useSeparator) {
if (LocaleController.isRTL) {
canvas.drawLine(0, getMeasuredHeight() - 1, getMeasuredWidth() - AndroidUtilities.dp(AndroidUtilities.leftBaseline), getMeasuredHeight() - 1, linePaint);
} else {
canvas.drawLine(AndroidUtilities.dp(AndroidUtilities.leftBaseline), getMeasuredHeight() - 1, getMeasuredWidth(), getMeasuredHeight() - 1, linePaint);
}
}
if (drawAlpha != 1) {
canvas.saveLayerAlpha(0, 0, canvas.getWidth(), canvas.getHeight(), (int)(255 * drawAlpha), Canvas.HAS_ALPHA_LAYER_SAVE_FLAG);
}
if (drawNameLock) {
setDrawableBounds(lockDrawable, nameLockLeft, nameLockTop);
lockDrawable.draw(canvas);
} else if (drawNameGroup) {
setDrawableBounds(groupDrawable, nameLockLeft, nameLockTop);
groupDrawable.draw(canvas);
} else if (drawNameBroadcast) {
setDrawableBounds(broadcastDrawable, nameLockLeft, nameLockTop);
broadcastDrawable.draw(canvas);
} else if (drawNameBot) {
setDrawableBounds(botDrawable, nameLockLeft, nameLockTop);
botDrawable.draw(canvas);
}
if (nameLayout != null) {
canvas.save();
canvas.translate(nameLeft, nameTop);
nameLayout.draw(canvas);
canvas.restore();
if (drawCheck) {
if (LocaleController.isRTL) {
setDrawableBounds(checkDrawable, nameLeft - AndroidUtilities.dp(4) - checkDrawable.getIntrinsicWidth(), nameLockTop);
} else {
setDrawableBounds(checkDrawable, nameLeft + (int) nameLayout.getLineWidth(0) + AndroidUtilities.dp(4), nameLockTop);
}
checkDrawable.draw(canvas);
}
}
if (onlineLayout != null) {
canvas.save();
canvas.translate(onlineLeft, AndroidUtilities.dp(40));
onlineLayout.draw(canvas);
canvas.restore();
}
if (countLayout != null) {
if (MessagesController.getInstance().isDialogMuted(dialog_id)) {
setDrawableBounds(countDrawableGrey, countLeft - AndroidUtilities.dp(5.5f), countTop, countWidth + AndroidUtilities.dp(11), countDrawableGrey.getIntrinsicHeight());
countDrawableGrey.draw(canvas);
} else {
setDrawableBounds(countDrawable, countLeft - AndroidUtilities.dp(5.5f), countTop, countWidth + AndroidUtilities.dp(11), countDrawable.getIntrinsicHeight());
countDrawable.draw(canvas);
}
canvas.save();
canvas.translate(countLeft, countTop + AndroidUtilities.dp(4));
countLayout.draw(canvas);
canvas.restore();
}
avatarImage.draw(canvas);
isOnline= OnlineDrawableHelper.isOnline(user);
if(BuildConfig.DEBUG)
if(isOnline && drawOnline){
if(BuildConfig.DEBUG)
OnlineDrawableHelper.draw(this, canvas, avatarTop,avatarLeft);
}
}
示例9: draw
import android.graphics.Canvas; //導入方法依賴的package包/類
void draw(Canvas canvas) {
int width = this.mBounds.width();
int height = this.mBounds.height();
int cx = width / 2;
int cy = height / 2;
boolean drawTriggerWhileFinishing = false;
int restoreCount = canvas.save();
canvas.clipRect(this.mBounds);
if (this.mRunning || this.mFinishTime > 0) {
Canvas canvas2;
long now = AnimationUtils.currentAnimationTimeMillis();
long iterations = (now - this.mStartTime) / SPConstant.DELAY_BUFFER_DURATION;
float rawProgress = ((float) ((now - this.mStartTime) % SPConstant.DELAY_BUFFER_DURATION)) / TitleBar.BACKBTN_LEFT_MARGIN;
if (!this.mRunning) {
if (now - this.mFinishTime >= 1000) {
this.mFinishTime = 0;
return;
}
float clearRadius = ((float) (width / 2)) * INTERPOLATOR.getInterpolation((((float) ((now - this.mFinishTime) % 1000)) / TitleBar.SHAREBTN_RIGHT_MARGIN) / 100.0f);
this.mClipRect.set(((float) cx) - clearRadius, 0.0f, ((float) cx) + clearRadius, (float) height);
canvas.saveLayerAlpha(this.mClipRect, 0, 0);
drawTriggerWhileFinishing = true;
}
if (iterations == 0) {
canvas.drawColor(this.mColor1);
} else if (rawProgress >= 0.0f && rawProgress < 25.0f) {
canvas.drawColor(this.mColor4);
} else if (rawProgress >= 25.0f && rawProgress < 50.0f) {
canvas.drawColor(this.mColor1);
} else if (rawProgress < 50.0f || rawProgress >= 75.0f) {
canvas.drawColor(this.mColor3);
} else {
canvas.drawColor(this.mColor2);
}
if (rawProgress >= 0.0f && rawProgress <= 25.0f) {
canvas2 = canvas;
drawCircle(canvas2, (float) cx, (float) cy, this.mColor1, ((25.0f + rawProgress) * 2.0f) / 100.0f);
}
if (rawProgress >= 0.0f && rawProgress <= 50.0f) {
canvas2 = canvas;
drawCircle(canvas2, (float) cx, (float) cy, this.mColor2, (2.0f * rawProgress) / 100.0f);
}
if (rawProgress >= 25.0f && rawProgress <= 75.0f) {
canvas2 = canvas;
drawCircle(canvas2, (float) cx, (float) cy, this.mColor3, ((rawProgress - 25.0f) * 2.0f) / 100.0f);
}
if (rawProgress >= 50.0f && rawProgress <= 100.0f) {
canvas2 = canvas;
drawCircle(canvas2, (float) cx, (float) cy, this.mColor4, ((rawProgress - 50.0f) * 2.0f) / 100.0f);
}
if (rawProgress >= 75.0f && rawProgress <= 100.0f) {
canvas2 = canvas;
drawCircle(canvas2, (float) cx, (float) cy, this.mColor1, ((rawProgress - 75.0f) * 2.0f) / 100.0f);
}
if (this.mTriggerPercentage > 0.0f && drawTriggerWhileFinishing) {
canvas.restoreToCount(restoreCount);
restoreCount = canvas.save();
canvas.clipRect(this.mBounds);
drawTrigger(canvas, cx, cy);
}
ViewCompat.postInvalidateOnAnimation(this.mParent, this.mBounds.left, this.mBounds.top, this.mBounds.right, this.mBounds.bottom);
} else if (this.mTriggerPercentage > 0.0f && ((double) this.mTriggerPercentage) <= 1.0d) {
drawTrigger(canvas, cx, cy);
}
canvas.restoreToCount(restoreCount);
}
示例10: onDraw
import android.graphics.Canvas; //導入方法依賴的package包/類
@Override
protected void onDraw(Canvas canvas) {
if (user == null && chat == null && encryptedChat == null) {
return;
}
if (useSeparator) {
if (LocaleController.isRTL) {
canvas.drawLine(0, getMeasuredHeight() - 1, getMeasuredWidth() - AndroidUtilities.dp(AndroidUtilities.leftBaseline), getMeasuredHeight() - 1, linePaint);
} else {
canvas.drawLine(AndroidUtilities.dp(AndroidUtilities.leftBaseline), getMeasuredHeight() - 1, getMeasuredWidth(), getMeasuredHeight() - 1, linePaint);
}
}
if (drawAlpha != 1) {
canvas.saveLayerAlpha(0, 0, canvas.getWidth(), canvas.getHeight(), (int)(255 * drawAlpha), Canvas.HAS_ALPHA_LAYER_SAVE_FLAG);
}
if (drawNameLock) {
setDrawableBounds(lockDrawable, nameLockLeft, nameLockTop);
lockDrawable.draw(canvas);
} else if (drawNameGroup) {
//setDrawableBounds(groupDrawable, nameLockLeft, nameLockTop);
//groupDrawable.draw(canvas);
if(chat.megagroup){
setDrawableBounds(superGroupDrawable, nameLockLeft, nameLockTop);
superGroupDrawable.draw(canvas);
}else{
setDrawableBounds(groupDrawable, nameLockLeft, nameLockTop);
groupDrawable.draw(canvas);
}
} else if (drawNameBroadcast) {
setDrawableBounds(broadcastDrawable, nameLockLeft, nameLockTop);
broadcastDrawable.draw(canvas);
} else if (drawNameBot) {
setDrawableBounds(botDrawable, nameLockLeft, nameLockTop);
botDrawable.draw(canvas);
}
if (nameLayout != null) {
canvas.save();
canvas.translate(nameLeft, nameTop);
nameLayout.draw(canvas);
canvas.restore();
if (drawCheck) {
if (LocaleController.isRTL) {
setDrawableBounds(checkDrawable, nameLeft - AndroidUtilities.dp(4) - checkDrawable.getIntrinsicWidth(), nameLockTop);
} else {
setDrawableBounds(checkDrawable, nameLeft + (int) nameLayout.getLineWidth(0) + AndroidUtilities.dp(4), nameLockTop);
}
checkDrawable.draw(canvas);
}
}
if (onlineLayout != null) {
canvas.save();
canvas.translate(onlineLeft, AndroidUtilities.dp(40));
onlineLayout.draw(canvas);
canvas.restore();
}
if (countLayout != null) {
if (MessagesController.getInstance().isDialogMuted(dialog_id)) {
setDrawableBounds(countDrawableGrey, countLeft - AndroidUtilities.dp(5.5f), countTop, countWidth + AndroidUtilities.dp(11), countDrawableGrey.getIntrinsicHeight());
countDrawableGrey.draw(canvas);
} else {
setDrawableBounds(countDrawable, countLeft - AndroidUtilities.dp(5.5f), countTop, countWidth + AndroidUtilities.dp(11), countDrawable.getIntrinsicHeight());
countDrawable.draw(canvas);
}
canvas.save();
canvas.translate(countLeft, countTop + AndroidUtilities.dp(4));
countLayout.draw(canvas);
canvas.restore();
}
avatarImage.draw(canvas);
}
示例11: draw
import android.graphics.Canvas; //導入方法依賴的package包/類
void draw(Canvas canvas) {
int width = this.mBounds.width();
int height = this.mBounds.height();
int cx = width / 2;
int cy = height / 2;
boolean drawTriggerWhileFinishing = false;
int restoreCount = canvas.save();
canvas.clipRect(this.mBounds);
if (this.mRunning || this.mFinishTime > 0) {
Canvas canvas2;
long now = AnimationUtils.currentAnimationTimeMillis();
long iterations = (now - this.mStartTime) / 2000;
float rawProgress = ((float) ((now - this.mStartTime) % 2000)) / 20.0f;
if (!this.mRunning) {
if (now - this.mFinishTime >= 1000) {
this.mFinishTime = 0;
return;
}
float clearRadius = ((float) (width / 2)) * INTERPOLATOR.getInterpolation((((float) ((now - this.mFinishTime) % 1000)) / 10.0f) / 100.0f);
this.mClipRect.set(((float) cx) - clearRadius, 0.0f, ((float) cx) + clearRadius, (float) height);
canvas.saveLayerAlpha(this.mClipRect, 0, 0);
drawTriggerWhileFinishing = true;
}
if (iterations == 0) {
canvas.drawColor(this.mColor1);
} else if (rawProgress >= 0.0f && rawProgress < 25.0f) {
canvas.drawColor(this.mColor4);
} else if (rawProgress >= 25.0f && rawProgress < IntFloatWheelView.DEFAULT_VALUE) {
canvas.drawColor(this.mColor1);
} else if (rawProgress < IntFloatWheelView.DEFAULT_VALUE || rawProgress >= 75.0f) {
canvas.drawColor(this.mColor3);
} else {
canvas.drawColor(this.mColor2);
}
if (rawProgress >= 0.0f && rawProgress <= 25.0f) {
canvas2 = canvas;
drawCircle(canvas2, (float) cx, (float) cy, this.mColor1, ((25.0f + rawProgress) * 2.0f) / 100.0f);
}
if (rawProgress >= 0.0f && rawProgress <= IntFloatWheelView.DEFAULT_VALUE) {
canvas2 = canvas;
drawCircle(canvas2, (float) cx, (float) cy, this.mColor2, (2.0f * rawProgress) / 100.0f);
}
if (rawProgress >= 25.0f && rawProgress <= 75.0f) {
canvas2 = canvas;
drawCircle(canvas2, (float) cx, (float) cy, this.mColor3, ((rawProgress - 25.0f) * 2.0f) / 100.0f);
}
if (rawProgress >= IntFloatWheelView.DEFAULT_VALUE && rawProgress <= 100.0f) {
canvas2 = canvas;
drawCircle(canvas2, (float) cx, (float) cy, this.mColor4, ((rawProgress - IntFloatWheelView.DEFAULT_VALUE) * 2.0f) / 100.0f);
}
if (rawProgress >= 75.0f && rawProgress <= 100.0f) {
canvas2 = canvas;
drawCircle(canvas2, (float) cx, (float) cy, this.mColor1, ((rawProgress - 75.0f) * 2.0f) / 100.0f);
}
if (this.mTriggerPercentage > 0.0f && drawTriggerWhileFinishing) {
canvas.restoreToCount(restoreCount);
restoreCount = canvas.save();
canvas.clipRect(this.mBounds);
drawTrigger(canvas, cx, cy);
}
ViewCompat.postInvalidateOnAnimation(this.mParent, this.mBounds.left, this.mBounds.top, this.mBounds.right, this.mBounds.bottom);
} else if (this.mTriggerPercentage > 0.0f && ((double) this.mTriggerPercentage) <= PathListView.NO_ZOOM) {
drawTrigger(canvas, cx, cy);
}
canvas.restoreToCount(restoreCount);
}