List of usage examples for android.graphics Canvas save
public int save()
From source file:com.ahamed.multiviewadapter.util.SimpleDividerDecoration.java
@SuppressLint("NewApi") private void drawVertical(Canvas canvas, RecyclerView parent, View child) { canvas.save(); final int left; final int right; if (parent.getClipToPadding()) { left = parent.getPaddingLeft();//from www . j av a 2 s .c o m right = parent.getWidth() - parent.getPaddingRight(); canvas.clipRect(left, parent.getPaddingTop(), right, parent.getHeight() - parent.getPaddingBottom()); } else { left = 0; right = parent.getWidth(); } parent.getDecoratedBoundsWithMargins(child, mBounds); final int bottom = mBounds.bottom + Math.round(ViewCompat.getTranslationY(child)); final int top = bottom - mDivider.getIntrinsicHeight(); mDivider.setBounds(left, top, right, bottom); mDivider.draw(canvas); canvas.restore(); }
From source file:com.ahamed.multiviewadapter.util.SimpleDividerDecoration.java
@SuppressLint("NewApi") private void drawHorizontal(Canvas canvas, RecyclerView parent, View child) { canvas.save(); final int top; final int bottom; if (parent.getClipToPadding()) { top = parent.getPaddingTop();/*from w ww .j a v a 2 s. c om*/ bottom = parent.getHeight() - parent.getPaddingBottom(); canvas.clipRect(parent.getPaddingLeft(), top, parent.getWidth() - parent.getPaddingRight(), bottom); } else { top = 0; bottom = parent.getHeight(); } parent.getLayoutManager().getDecoratedBoundsWithMargins(child, mBounds); final int right = mBounds.right + Math.round(ViewCompat.getTranslationX(child)); final int left = right - mDivider.getIntrinsicWidth(); mDivider.setBounds(left, top, right, bottom); mDivider.draw(canvas); canvas.restore(); }
From source file:com.hippo.nimingban.widget.BottomShadowScrollView.java
@Override protected void dispatchDraw(@NonNull Canvas canvas) { super.dispatchDraw(canvas); mShadowDrawable.setBounds(0, 0, getWidth(), mShadowHeight); int saved = canvas.save(); int height = getChildCount() != 0 ? Math.max(getChildAt(0).getHeight(), getHeight()) : getHeight(); canvas.translate(0, height - mShadowHeight); mShadowDrawable.draw(canvas);/* www. ja va2s. c o m*/ canvas.restoreToCount(saved); }
From source file:foam.jellyfish.StarwispCanvas.java
public void DrawText(Canvas canvas, JSONArray prim, float sx, float sy) { try {//from ww w. j a v a 2 s.c om canvas.save(); if (prim.getString(6).equals("vertical")) canvas.rotate(-90, prim.getInt(2) * sx, prim.getInt(3) * sy); Paint myPaint = new Paint(); JSONArray c = prim.getJSONArray(4); myPaint.setColor(Color.rgb(c.getInt(0), c.getInt(1), c.getInt(2))); myPaint.setTextSize(prim.getInt(5)); myPaint.setTypeface(m_Typeface); canvas.drawText(prim.getString(1), prim.getInt(2) * sx, prim.getInt(3) * sy, myPaint); canvas.restore(); } catch (JSONException e) { Log.e("starwisp", "Error parsing data " + e.toString()); } }
From source file:android.support.v7.widget.DividerItemDecoration.java
private void drawVertical(Canvas canvas, RecyclerView parent) { canvas.save(); final int left; final int right; if (parent.getClipToPadding()) { left = parent.getPaddingLeft();/*from w w w. j av a 2 s . c o m*/ right = parent.getWidth() - parent.getPaddingRight(); canvas.clipRect(left, parent.getPaddingTop(), right, parent.getHeight() - parent.getPaddingBottom()); } else { left = 0; right = parent.getWidth(); } final int childCount = parent.getChildCount(); for (int i = 0; i < childCount; i++) { final View child = parent.getChildAt(i); parent.getDecoratedBoundsWithMargins(child, mBounds); final int bottom = mBounds.bottom + Math.round(ViewCompat.getTranslationY(child)); final int top = bottom - mDivider.getIntrinsicHeight(); mDivider.setBounds(left, top, right, bottom); mDivider.draw(canvas); } canvas.restore(); }
From source file:android.support.v7.widget.DividerItemDecoration.java
private void drawHorizontal(Canvas canvas, RecyclerView parent) { canvas.save(); final int top; final int bottom; if (parent.getClipToPadding()) { top = parent.getPaddingTop();/*from ww w. ja v a2 s. c om*/ bottom = parent.getHeight() - parent.getPaddingBottom(); canvas.clipRect(parent.getPaddingLeft(), top, parent.getWidth() - parent.getPaddingRight(), bottom); } else { top = 0; bottom = parent.getHeight(); } final int childCount = parent.getChildCount(); for (int i = 0; i < childCount; i++) { final View child = parent.getChildAt(i); parent.getLayoutManager().getDecoratedBoundsWithMargins(child, mBounds); final int right = mBounds.right + Math.round(ViewCompat.getTranslationX(child)); final int left = right - mDivider.getIntrinsicWidth(); mDivider.setBounds(left, top, right, bottom); mDivider.draw(canvas); } canvas.restore(); }
From source file:com.dbeginc.dbweather.utils.animations.widgets.RainFallView.java
@Override protected void onDraw(Canvas canvas) { for (int i = 0; i < mRainFlakeCount; i++) { Drawable drawable = drawables.get(i); canvas.save(); canvas.translate(coords[i][0], coords[i][1]); drawable.draw(canvas);/*from ww w. java 2 s . c om*/ canvas.restore(); } invalidate(); }
From source file:com.dbeginc.dbweather.utils.animations.widgets.SnowFallView.java
@Override protected void onDraw(Canvas canvas) { for (int i = 0; i < snow_flake_count; i++) { Drawable drawable = drawables.get(i); canvas.save(); canvas.translate(coords[i][0], coords[i][1]); drawable.draw(canvas);/*from w w w. j a v a2 s .co m*/ canvas.restore(); } invalidate(); }
From source file:com.by_syk.lib.nanoiconpack.widget.DividerItemDecoration.java
@SuppressLint("NewApi") private void drawHorizontal(Canvas canvas, RecyclerView parent) { canvas.save(); final int top; final int bottom; if (parent.getClipToPadding()) { top = parent.getPaddingTop();/*from ww w.j a v a2 s .co m*/ bottom = parent.getHeight() - parent.getPaddingBottom(); canvas.clipRect(parent.getPaddingLeft(), top, parent.getWidth() - parent.getPaddingRight(), bottom); } else { top = 0; bottom = parent.getHeight(); } final int childCount = parent.getChildCount(); for (int i = 0; i < childCount; i++) { final View child = parent.getChildAt(i); parent.getLayoutManager().getDecoratedBoundsWithMargins(child, mBounds); final int right = mBounds.right + Math.round(ViewCompat.getTranslationX(child)); final int left = right - mDivider.getIntrinsicWidth(); mDivider.setBounds(left, top, right, bottom); mDivider.draw(canvas); } canvas.restore(); }
From source file:com.by_syk.schttable.widget.DividerItemDecoration.java
@SuppressLint("NewApi") private void drawVertical(Canvas canvas, RecyclerView parent) { canvas.save(); final int left; final int right; if (parent.getClipToPadding()) { left = parent.getPaddingLeft();//ww w . j ava 2s .co m right = parent.getWidth() - parent.getPaddingRight(); canvas.clipRect(left, parent.getPaddingTop(), right, parent.getHeight() - parent.getPaddingBottom()); } else { left = 0; right = parent.getWidth(); } final int childCount = parent.getChildCount(); for (int i = 0; i < childCount; i++) { final View child = parent.getChildAt(i); parent.getDecoratedBoundsWithMargins(child, mBounds); final int bottom = mBounds.bottom + Math.round(ViewCompat.getTranslationY(child)); final int top = bottom - mDivider.getIntrinsicHeight(); mDivider.setBounds(left, top, right, bottom); mDivider.draw(canvas); } canvas.restore(); }