Java Code Examples for android.graphics.drawable.ShapeDrawable#draw()
The following examples show how to use
android.graphics.drawable.ShapeDrawable#draw() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GameView.java From CanEffect with Apache License 2.0 | 5 votes |
public void onDraw(Canvas canvas) { super.onDraw(canvas); //将图片裁剪为椭圆形 /* 构建ShapeDrawable对象并定义形状为椭圆 */ mShapeDrawableQQ = new ShapeDrawable(new OvalShape()); /* 设置要绘制的椭圆形的东西为ShapeDrawable图片 */ mShapeDrawableQQ.getPaint().setShader(mBitmapShader); /* 设置显示区域 */ mShapeDrawableQQ.setBounds(0,0, BitQQwidth, BitQQheight); /* 绘制ShapeDrawableQQ */ mShapeDrawableQQ.draw(canvas); //绘制渐变的矩形 mPaint.setShader(mLinearGradient); canvas.drawRect(BitQQwidth, 0, 320, 156, mPaint); //显示混合渲染效果 mPaint.setShader(mComposeShader); canvas.drawRect(0, 300, BitQQwidth, 300+BitQQheight, mPaint); //绘制环形渐变 mPaint.setShader(mRadialGradient); canvas.drawCircle(50, 200, 50, mPaint); //绘制梯度渐变 mPaint.setShader(mSweepGradient); canvas.drawRect(150, 160, 300, 300, mPaint); }
Example 2
Source File: ShadowLayout.java From ShadowLayout with MIT License | 4 votes |
private void setSpaceCorner(Canvas canvas, int trueHeight) { int leftTop; int rightTop; int rightBottom; int leftBottom; if (mCornerRadius_leftTop == -1) { leftTop = (int) mCornerRadius; } else { leftTop = (int) mCornerRadius_leftTop; } if (leftTop > trueHeight / 2) { leftTop = trueHeight / 2; } if (mCornerRadius_rightTop == -1) { rightTop = (int) mCornerRadius; } else { rightTop = (int) mCornerRadius_rightTop; } if (rightTop > trueHeight / 2) { rightTop = trueHeight / 2; } if (mCornerRadius_rightBottom == -1) { rightBottom = (int) mCornerRadius; } else { rightBottom = (int) mCornerRadius_rightBottom; } if (rightBottom > trueHeight / 2) { rightBottom = trueHeight / 2; } if (mCornerRadius_leftBottom == -1) { leftBottom = (int) mCornerRadius; } else { leftBottom = (int) mCornerRadius_leftBottom; } if (leftBottom > trueHeight / 2) { leftBottom = trueHeight / 2; } float[] outerR = new float[]{leftTop, leftTop, rightTop, rightTop, rightBottom, rightBottom, leftBottom, leftBottom};//左上,右上,右下,左下 ShapeDrawable mDrawables = new ShapeDrawable(new RoundRectShape(outerR, null, null)); mDrawables.getPaint().setColor(paint.getColor()); mDrawables.setBounds(leftPading, topPading, getWidth() - rightPading, getHeight() - bottomPading); mDrawables.draw(canvas); }
Example 3
Source File: Report2DChartView.java From financisto with GNU General Public License v2.0 | 4 votes |
/** * Draw points in chart. * * @param canvas Canvas to draw the chart. */ private void drawPoints(Canvas canvas) { for (ShapeDrawable pointsShape : pointsShapes) { pointsShape.draw(canvas); } }