當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。