List of usage examples for android.graphics Canvas save
public int save()
From source file:im.ene.lab.io_timer.ui.widget.MiniDrawerLayout.java
@Override protected boolean drawChild(Canvas canvas, View child, long drawingTime) { final int restoreCount = canvas.save(); final boolean result = super.drawChild(canvas, child, drawingTime); canvas.restoreToCount(restoreCount); return result; }
From source file:com.chartiq.chartiqsample.ui.StickyHeaderDecoration.java
/** * {@inheritDoc}/*from ww w.j av a2 s.com*/ */ @Override public void onDrawOver(Canvas canvas, RecyclerView parent, RecyclerView.State state) { final int count = parent.getChildCount(); long previousHeaderId = -1; for (int layoutPos = 0; layoutPos < count; layoutPos++) { final View child = parent.getChildAt(layoutPos); final int adapterPos = parent.getChildAdapterPosition(child); if (child.getVisibility() == View.GONE) { continue; } if (adapterPos != RecyclerView.NO_POSITION && hasHeader(adapterPos)) { long headerId = mAdapter.getHeaderId(adapterPos); if (headerId != previousHeaderId) { previousHeaderId = headerId; View header = getHeader(parent, adapterPos).itemView; canvas.save(); final int left = child.getLeft(); final int top = getHeaderTop(parent, child, header, adapterPos, layoutPos); canvas.translate(left, top); header.setTranslationX(left); header.setTranslationY(top); header.draw(canvas); canvas.restore(); } } } }
From source file:com.android.photos.views.GalleryThumbnailView.java
@Override public void draw(Canvas canvas) { super.draw(canvas); if (!mLeftEdge.isFinished()) { final int restoreCount = canvas.save(); final int height = getHeight() - getPaddingTop() - getPaddingBottom(); canvas.rotate(270);/* w w w . j a v a 2 s. c om*/ canvas.translate(-height + getPaddingTop(), 0); mLeftEdge.setSize(height, getWidth()); if (mLeftEdge.draw(canvas)) { postInvalidateOnAnimation(); } canvas.restoreToCount(restoreCount); } if (!mRightEdge.isFinished()) { final int restoreCount = canvas.save(); final int width = getWidth(); final int height = getHeight() - getPaddingTop() - getPaddingBottom(); canvas.rotate(90); canvas.translate(-getPaddingTop(), width); mRightEdge.setSize(height, width); if (mRightEdge.draw(canvas)) { postInvalidateOnAnimation(); } canvas.restoreToCount(restoreCount); } }
From source file:com.dongdong.wheel.WheelView.java
/** * Draws items/*from www . j a v a 2 s .c om*/ * * @param canvas the canvas for drawing */ private void drawItems(Canvas canvas) { canvas.save(); int top = mItemsLayout.getLineTop(1); canvas.translate(0, -top + mScrollingOffset); mItemsPaint.setColor(ITEMS_TEXT_COLOR); mItemsPaint.drawableState = getDrawableState(); mItemsLayout.draw(canvas); canvas.restore(); }
From source file:cn.lanmei.com.dingdong_2.ItemDecoration.StickyHeaderDecoration.java
/** * {@inheritDoc}// ww w . j av a 2s . c o m */ @Override public void onDrawOver(Canvas c, RecyclerView parent, RecyclerView.State state) { // final int count = parent.getChildCount(); LRecyclerViewAdapter adapter = (LRecyclerViewAdapter) parent.getAdapter(); RecyclerView.Adapter ra = adapter.getInnerAdapter(); final int count = ra.getItemCount(); for (int layoutPos = 0; layoutPos < count; layoutPos++) { final View child = parent.getChildAt(layoutPos); final int adapterPos = parent.getChildAdapterPosition(child); // L.MyLog("sticky","onDrawOver:"+adapterPos+"getItemCount"+count); if (adapterPos != RecyclerView.NO_POSITION && (layoutPos == 0 || hasHeader(adapterPos))) { View header = getHeader(parent, adapterPos).itemView; c.save(); final int left = child.getLeft(); final int top = getHeaderTop(parent, child, header, adapterPos, layoutPos); c.translate(left, top); header.setTranslationX(left); header.setTranslationY(top); header.draw(c); c.restore(); } } }
From source file:com.mukesh.OtpView.java
@Override protected void onDraw(Canvas canvas) { canvas.save(); updatePaints(); drawOtpView(canvas); canvas.restore(); }
From source file:it.ndorigatti.android.view.MulticolorProgressBar.java
@Override protected synchronized void onDraw(Canvas canvas) { super.onDraw(canvas); Drawable d = mCurrentDrawable;/*from w ww. jav a2 s . com*/ if (d != null) { // Translate canvas so a indeterminate circular progress bar with padding // rotates properly in its animation canvas.save(); canvas.translate(getPaddingLeft(), getPaddingTop()); d.draw(canvas); canvas.restore(); } }
From source file:com.am.pagergradienttab.view.PagerGradientTabStrip.java
/** * /*from w w w. ja v a2s . c o m*/ * * @param canvas */ private void drawText(Canvas canvas) { float x = getPaddingLeft() + itemWidth / 2; int y = getHeight() - getPaddingBottom() - indicatorHeight - underLineHeight; int position = 0; for (String text : tabs) { canvas.save(); mTextPaint.setColor(textColorNormal); mTextPaint.setTextAlign(Align.LEFT); mTextPaint.setTextSize(textSize); if (showTextGradient) { if (position == nextPager) { mTextPaint.setColor(getColor(textColorNormal, textColorSelected, textSizeOffset)); } else if (position == currectPager) { mTextPaint.setColor(getColor(textColorNormal, textColorSelected, 1 - textSizeOffset)); } else { mTextPaint.setColor(textColorNormal); } } if (showTextScale) { if (position == nextPager) { canvas.translate(x - mTextPaint.measureText(text) * (1 + textSizeOffset * magnification) / 2, y - textTop); canvas.scale(1 + textSizeOffset * magnification, 1 + textSizeOffset * magnification); } else if (position == currectPager) { canvas.translate( x - mTextPaint.measureText(text) * (1 + (1 - textSizeOffset) * magnification) / 2, y - textTop); canvas.scale(1 + (1 - textSizeOffset) * magnification, 1 + (1 - textSizeOffset) * magnification); } else { canvas.translate(x - mTextPaint.measureText(text) / 2, y - textTop); canvas.scale(1, 1); } } else { canvas.translate(x - mTextPaint.measureText(text) / 2, y - textTop); } canvas.drawText(text, 0, 0, mTextPaint); x += itemWidth + intervalWidth; position++; canvas.restore(); } }
From source file:ru.mahortov.listviewcustom.ListView.PinnedSectionListView.java
@Override protected void dispatchDraw(@NonNull 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); }// w w w . j av a 2 s .c om canvas.restore(); } }
From source file:com.appsimobile.appsii.module.home.SunriseDrawable.java
private void drawSun(Canvas canvas, float pct) { // Draw the dots canvas.drawCircle(mBezier1x, mBezier1y, mDotRadius, mDotPaint); canvas.drawCircle(mBezier4x, mBezier4y, mDotRadius, mDotPaint); // calculate the center point of the sun image float x = bezierInterpolation(pct, mBezier1x, mBezier2x, mBezier3x, mBezier4x); float y = bezierInterpolation(pct, mBezier1y, mBezier2y, mBezier3y, mBezier4y); Rect sunBounds = mSunImage.getBounds(); x -= sunBounds.width() / 2;// w w w . j ava 2s.c o m y -= sunBounds.height() / 2; // if we are in rtl, we still want to show the image normally // so flip it back canvas.translate(x, y); if (mIsRtl) { canvas.save(); canvas.scale(-1, 1, sunBounds.centerX(), sunBounds.centerY()); } // draw the sun image mSunImage.draw(canvas); // restore the flip again if (mIsRtl) { canvas.restore(); } canvas.translate(-x, -y); }