当前位置: 首页>>代码示例>>Java>>正文


Java Canvas.saveLayerAlpha方法代码示例

本文整理汇总了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);
    }
}
 
开发者ID:MLNO,项目名称:airgram,代码行数:19,代码来源:LetterSectionsListView.java

示例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();
}
 
开发者ID:mainh,项目名称:MainCalendar,代码行数:20,代码来源:SwitchButton.java

示例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();
}
 
开发者ID:nhocga1995s,项目名称:MyCalendar,代码行数:8,代码来源:FloatingActionButtonLibrary.java

示例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();
}
 
开发者ID:HelloChenJinJun,项目名称:TestChat,代码行数:8,代码来源:FloatingActionButton.java

示例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);
}
 
开发者ID:monthlypub,项目名称:SmingZZick_App,代码行数:38,代码来源:TextStickerAttachInfo.java

示例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);
    }
}
 
开发者ID:52inc,项目名称:CanvasScript,代码行数:9,代码来源:SaveLayerParams.java

示例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();
    }
}
 
开发者ID:ultrasonic,项目名称:ultrasonic,代码行数:47,代码来源:DragSortListView.java

示例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);
    }
}
 
开发者ID:MLNO,项目名称:airgram,代码行数:78,代码来源:ProfileSearchCell.java

示例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);
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:67,代码来源:SwipeProgressBar.java

示例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);
}
 
开发者ID:pooyafaroka,项目名称:PlusGram,代码行数:78,代码来源:ProfileSearchCell.java

示例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);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:67,代码来源:SwipeProgressBar.java


注:本文中的android.graphics.Canvas.saveLayerAlpha方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。