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


Java Canvas.clipRect方法代码示例

本文整理汇总了Java中android.graphics.Canvas.clipRect方法的典型用法代码示例。如果您正苦于以下问题:Java Canvas.clipRect方法的具体用法?Java Canvas.clipRect怎么用?Java Canvas.clipRect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.graphics.Canvas的用法示例。


在下文中一共展示了Canvas.clipRect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onDispatchDrawOccurred

import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
public void onDispatchDrawOccurred(Canvas canvas) {
    // onScroll is not called often at all before froyo
    // therefor we need to update the header here as well.
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.FROYO) {
        updateOrClearHeader(mList.getFixedFirstVisibleItem());
    }
    if (mHeader != null) {
        if (mClippingToPadding) {
            canvas.save();
            canvas.clipRect(0, mPaddingTop, getRight(), getBottom());
            drawChild(canvas, mHeader, 0);
            canvas.restore();
        } else {
            drawChild(canvas, mHeader, 0);
        }
    }
}
 
开发者ID:SavorGit,项目名称:Hotspot-master-devp,代码行数:19,代码来源:StickyListHeadersListView.java

示例2: drawExplosion

import android.graphics.Canvas; //导入方法依赖的package包/类
/**
 * 绘制Boss爆炸的状态
 *
 * @param canvas
 */
private void drawExplosion(Canvas canvas) {
    // 绘制爆炸时的图片
    int y = (int) (currentFrame * object_height);
    canvas.save();
    canvas.clipRect(object_x, object_y, object_x + object_width,
            object_y + object_height);
    canvas.drawBitmap(boosPlaneBomb, object_x, object_y - y, paint);
    canvas.restore();

    // 绘制帧动画
    currentFrame++;
    if (currentFrame >= 5) {
        currentFrame = 0;
        isExplosion = false;
        isAlive = false;
        if (bulletType != ConstantUtil.BOSSBULLET_DEFAULT) {
            changeBullet(ConstantUtil.BOSSBULLET_DEFAULT);
        }
    }
}
 
开发者ID:HurTeng,项目名称:StormPlane,代码行数:26,代码来源:BossPlane.java

示例3: onChildDraw

import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
public void onChildDraw(Canvas c, RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, float dX, float dY, int actionState, boolean isCurrentlyActive) {
    if (actionState == ItemTouchHelper.ACTION_STATE_SWIPE) {
        View view = viewHolder.itemView;
        c.save();
        mSwipePaint.setAlpha((int) (255 * view.getAlpha()));
        mDeleteIcon.setAlpha((int) (255 * view.getAlpha()));
        int sw = mDeleteIcon.getIntrinsicWidth();
        int sh = mDeleteIcon.getIntrinsicHeight();
        int cx;
        int cy = (view.getTop() + view.getBottom()) / 2;
        if (dX > 0.f) {
            mTempRect.set(view.getLeft(), view.getTop(), (int) dX, view.getBottom());
            cx = view.getLeft() + mIconPadding + sw / 2;
        } else {
            mTempRect.set(view.getRight() + (int) dX, view.getTop(), view.getRight(), view.getBottom());
            cx = view.getRight() - mIconPadding - sw / 2;
        }
        mDeleteIcon.setBounds(cx - sw / 2, cy - sh / 2, cx + sw / 2, cy + sh / 2);
        c.drawRect(mTempRect, mSwipePaint);
        c.clipRect(mTempRect);
        mDeleteIcon.draw(c);
        c.restore();
    }
    super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive);
}
 
开发者ID:MCMrARM,项目名称:revolution-irc,代码行数:27,代码来源:NotificationRulesAdapter.java

示例4: drawChild

import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
protected boolean drawChild(Canvas canvas, View child, long drawingTime) {
    int restoreToCount = canvas.save();
    if (yPosition < 0) {
        canvas.clipRect(0, (int) -yPosition, child.getMeasuredWidth(), AndroidUtilities.dp(39));
    }
    final boolean result = super.drawChild(canvas, child, drawingTime);
    canvas.restoreToCount(restoreToCount);
    return result;
}
 
开发者ID:MLNO,项目名称:airgram,代码行数:11,代码来源:PlayerView.java

示例5: drawScrim

import android.graphics.Canvas; //导入方法依赖的package包/类
private void drawScrim(Canvas canvas, View child) {
    final int baseAlpha = (mScrimColor & 0xff000000) >>> 24;
    final int alpha = (int) (baseAlpha * mScrimOpacity);
    final int color = alpha << 24 | (mScrimColor & 0xffffff);
    canvas.clipRect(0, 0, child.getLeft(), getHeight());
    canvas.drawColor(color);
}
 
开发者ID:wheat7,项目名称:Cashew,代码行数:8,代码来源:SwipeBackLayout.java

示例6: renderLimitLines

import android.graphics.Canvas; //导入方法依赖的package包/类
/**
 * Draws the LimitLines associated with this axis to the screen.
 *
 * @param c
 */
@Override
public void renderLimitLines(Canvas c) {

    List<LimitLine> limitLines = mXAxis.getLimitLines();

    if (limitLines == null || limitLines.size() <= 0)
        return;

    float[] position = mRenderLimitLinesBuffer;
    position[0] = 0;
    position[1] = 0;

    for (int i = 0; i < limitLines.size(); i++) {

        LimitLine l = limitLines.get(i);

        if (!l.isEnabled())
            continue;

        int clipRestoreCount = c.save();
        mLimitLineClippingRect.set(mViewPortHandler.getContentRect());
        mLimitLineClippingRect.inset(-l.getLineWidth(), 0.f);
        c.clipRect(mLimitLineClippingRect);

        position[0] = l.getLimit();
        position[1] = 0.f;

        mTrans.pointValuesToPixel(position);

        renderLimitLineLine(c, l, position);
        renderLimitLineLabel(c, l, position, 2.f + l.getYOffset());

        c.restoreToCount(clipRestoreCount);
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:41,代码来源:XAxisRenderer.java

示例7: drawChild

import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
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;
}
 
开发者ID:dibakarece,项目名称:DMAudioStreamer,代码行数:39,代码来源:SlidingUpPanelLayout.java

示例8: drawChild

import android.graphics.Canvas; //导入方法依赖的package包/类
protected boolean drawChild(Canvas canvas, View child, long drawingTime) {
    boolean result;
    LayoutParams lp = (LayoutParams) child.getLayoutParams();
    int save = canvas.save(2);
    if (!(!this.mCanSlide || lp.slideable || this.mSlideableView == null)) {
        canvas.getClipBounds(this.mTmpRect);
        if (isLayoutRtlSupport()) {
            this.mTmpRect.left = Math.max(this.mTmpRect.left, this.mSlideableView.getRight());
        } else {
            this.mTmpRect.right = Math.min(this.mTmpRect.right, this.mSlideableView.getLeft());
        }
        canvas.clipRect(this.mTmpRect);
    }
    if (VERSION.SDK_INT >= 11) {
        result = super.drawChild(canvas, child, drawingTime);
    } else if (!lp.dimWhenOffset || this.mSlideOffset <= 0.0f) {
        if (child.isDrawingCacheEnabled()) {
            child.setDrawingCacheEnabled(false);
        }
        result = super.drawChild(canvas, child, drawingTime);
    } else {
        if (!child.isDrawingCacheEnabled()) {
            child.setDrawingCacheEnabled(true);
        }
        Bitmap cache = child.getDrawingCache();
        if (cache != null) {
            canvas.drawBitmap(cache, (float) child.getLeft(), (float) child.getTop(), lp.dimPaint);
            result = false;
        } else {
            Log.e(TAG, "drawChild: child view " + child + " returned null drawing cache");
            result = super.drawChild(canvas, child, drawingTime);
        }
    }
    canvas.restoreToCount(save);
    return result;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:37,代码来源:SlidingPaneLayout.java

示例9: drawShadow

import android.graphics.Canvas; //导入方法依赖的package包/类
private void drawShadow(Canvas canvas) {
    if (shadowDrawable != null) {

        Rect newRect = canvas.getClipBounds();
        Log.d(TAG,"ShadowParentView has blur! " + newRect);
        newRect.inset(-shadowPadding, -shadowPadding);
        canvas.clipRect (newRect, Region.Op.REPLACE);

        shadowDrawable.draw(canvas);
    }
}
 
开发者ID:wix,项目名称:react-native-andorid-shadow,代码行数:12,代码来源:ShadowParentView.java

示例10: onDrawOver

import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
public void onDrawOver(Canvas c, RecyclerView parent, RecyclerView.State state) {
    if (mPinnedHeaderView != null) {
        c.save();

        mClipBounds.top = 0;
        c.clipRect(mClipBounds, Region.Op.UNION);
        c.translate(0, mPinnedHeaderTop);
        mPinnedHeaderView.draw(c);

        c.restore();
    }
}
 
开发者ID:lvtanxi,项目名称:BaseVLayoutAdapterHelper,代码行数:14,代码来源:SectionDecoration.java

示例11: drawAppName

import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
public void drawAppName(Canvas canvas, float fraction, String name, int colorOfAppName,
                        WidthAndHeightOfView widthAndHeightOfView) {
    canvas.save();
    int width = widthAndHeightOfView.getWidth();
    int height = widthAndHeightOfView.getHeight();
    canvas.clipRect(width / 2 - 150, height / 2 - 80,
            width / 2 + 150 * fraction, height / 2 + 65 * fraction);
    Paint paint = new Paint();
    paint.setColor(colorOfAppName);
    paint.setTextAlign(Paint.Align.CENTER);
    paint.setTextSize(50);
    canvas.drawText(name, width / 2, height / 2 + 50, paint);
    canvas.restore();
}
 
开发者ID:JoshuaRogue,项目名称:FancyView,代码行数:16,代码来源:RotationDrawStrategy.java

示例12: draw

import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
public void draw(Canvas canvas){
   if(topDown){
      canvas.translate(getHeight(), 0);
      canvas.rotate(90);
   }else {
      canvas.translate(0, getWidth());
      canvas.rotate(-90);
   }
   canvas.clipRect(0, 0, getWidth(), getHeight(), android.graphics.Region.Op.REPLACE);
   super.draw(canvas);
}
 
开发者ID:h4h13,项目名称:RetroMusicPlayer,代码行数:13,代码来源:VerticalTextView.java

示例13: drawSelf

import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
public void drawSelf(Canvas canvas) {
	if (isAlive) {
		canvas.save();
		canvas.clipRect(object_x, object_y, object_x + object_width,
				object_y + object_height);
		canvas.drawBitmap(bullet, object_x, object_y, paint);
		canvas.restore();
		logic();
	}
}
 
开发者ID:HurTeng,项目名称:StormPlane,代码行数:12,代码来源:BossYHellfireBullet.java

示例14: onDraw

import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
public void onDraw(Canvas c) {
    // Draw the background
    if (mEmptySearchBackground != null && mEmptySearchBackground.getAlpha() > 0) {
        c.clipRect(mBackgroundPadding.left, mBackgroundPadding.top,
                getWidth() - mBackgroundPadding.right,
                getHeight() - mBackgroundPadding.bottom);

        mEmptySearchBackground.draw(c);
    }

    super.onDraw(c);
}
 
开发者ID:TeamBrainStorm,项目名称:SimpleUILauncher,代码行数:14,代码来源:AllAppsRecyclerView.java

示例15: dispatchDraw

import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
protected void dispatchDraw(Canvas canvas) {
  super.dispatchDraw(canvas);

  if (mPinnedSection != null) {

    // prepare variables
    int pLeft = getListPaddingLeft();
    int pTop = getListPaddingTop();
    View view = mPinnedSection.view;

    // draw child
    canvas.save();

    int clipHeight = view.getHeight() +
        (mShadowDrawable == null ? 0 : Math.min(mShadowHeight, mSectionsDistanceY));
    canvas.clipRect(pLeft, pTop, pLeft + view.getWidth(), pTop + clipHeight);

    canvas.translate(pLeft, pTop + mTranslateY);
    drawChild(canvas, mPinnedSection.view, getDrawingTime());

    if (mShadowDrawable != null && mSectionsDistanceY > 0) {
      mShadowDrawable.setBounds(mPinnedSection.view.getLeft(),
          mPinnedSection.view.getBottom(),
          mPinnedSection.view.getRight(),
          mPinnedSection.view.getBottom() + mShadowHeight);
      mShadowDrawable.draw(canvas);
    }

    canvas.restore();
  }
}
 
开发者ID:nordfalk,项目名称:EsperantoRadio,代码行数:33,代码来源:PinnedSectionListView.java


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