错误:保存在类Canvas中的方法无法应用于给定类型;

时间:2019-07-07 21:06:14

标签: android android-studio

错误API 28如何修复代码?

protected boolean drawChild(Canvas canvas, View child, long drawingTime) {
    boolean result;
    final int save = canvas.save(Canvas.CLIP_SAVE_FLAG);

    if (mSlideableView != child) { // if main view
        // Clip against the slider; no sense drawing what will immediately
        // be covered,
        // Unless the panel is set to overlay content
        canvas.getClipBounds(mTmpRect);
        if (!mOverlayContent) {
            if (mIsSlidingUp) {
                mTmpRect.bottom = Math.min(mTmpRect.bottom, mSlideableView.getTop());
            } else {
                mTmpRect.top = Math.max(mTmpRect.top, mSlideableView.getBottom());
            }
        }
        if (mClipPanel) {
            canvas.clipRect(mTmpRect);
        }

        result = super.drawChild(canvas, child, drawingTime);

        if (mCoveredFadeColor != 0 && mSlideOffset > 0) {
            final int baseAlpha = (mCoveredFadeColor & 0xff000000) >>> 24;
            final int imag = (int) (baseAlpha * mSlideOffset);
            final int color = imag << 24 | (mCoveredFadeColor & 0xffffff);
            mCoveredFadePaint.setColor(color);
            canvas.drawRect(mTmpRect, mCoveredFadePaint);
        }
    } else {
        result = super.drawChild(canvas, child, drawingTime);
    }

    canvas.restoreToCount(save);

    return result;
}

错误在给定的行中。 final int save = canvas.save(Canvas.CLIP_SAVE_FLAG);

如何解决该错误? API28删除了此功能。我需要您的帮助进行修复。在编译时不会导致错误。谢谢

0 个答案:

没有答案