用canvas画只有一个角是圆角的矩形,能画出来么?
来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/22 16:06:53
用canvas画只有一个角是圆角的矩形,能画出来么?
用canvas画只有一个角是圆角的矩形,能画出来么?
用canvas画只有一个角是圆角的矩形,能画出来么?
public static Bitmap getRoundedCornerBitmap(Bitmap bitmap,float roundPx) { Bitmap output = Bitmap.createBitmap(bitmap.getWidth(),bitmap.getHeight(),Config.ARGB_8888); Canvas canvas = new Canvas(output); final int color = 0xff424242; final Paint paint = new Paint(); final Rect rect = new Rect(0,0,bitmap.getWidth(),bitmap.getHeight()); final RectF rectF = new RectF(rect); paint.setAntiAlias(true); canvas.drawARGB(0,0,0,0); paint.setColor(color); canvas.drawRoundRect(rectF,roundPx,roundPx,paint); paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN)); canvas.drawBitmap(bitmap,rect,rect,paint); return output; } 查看原帖>>
int x = 10; int y = 10; int width = 300; int height = 50; float[] outerR = new float[] { 12, 12, 0, 0, 0, 0, 30, 30 }; RoundRectShape rectShape=new RoundRectShape(outerR, null, null); ShapeDrawable mD...
全部展开
int x = 10; int y = 10; int width = 300; int height = 50; float[] outerR = new float[] { 12, 12, 0, 0, 0, 0, 30, 30 }; RoundRectShape rectShape=new RoundRectShape(outerR, null, null); ShapeDrawable mDrawables= new ShapeDrawable(new RoundRectShape(outerR, null,null)); mDrawables.getPaint().setColor(Color.RED); mDrawables.setBounds(x, y, x + width, y + height); mDrawables.draw(canvas);费了九牛二虎之力终于找到点踪迹了,基本上搞定 查看原帖>>
收起
找到方法了float[] radii={12f,12f,0f,0f,0f,0f,0f,0f};path.addRoundRect(new RectF(0, 0, 50, 50), radii, Path.Direction.CW);canvas.drawPath(path,paint); 查看原帖>>
int x = 10; int y = 10; int width = 300; int height = 50; float[] outerR = new float[] { 12, 12, 0, 0, 0, 0, 30, 30 }; RoundRectShape rectShape=new RoundRectShape(outerR, null, null); ShapeDrawable mD...
全部展开
int x = 10; int y = 10; int width = 300; int height = 50; float[] outerR = new float[] { 12, 12, 0, 0, 0, 0, 30, 30 }; RoundRectShape rectShape=new RoundRectShape(outerR, null, null); ShapeDrawable mDrawables= new ShapeDrawable(new RoundRectShape(outerR, null,null)); mDrawables.getPaint().setColor(Color.RED); mDrawables.setBounds(x, y, x + width, y + height); mDrawables.draw(canvas);费了九牛二虎之力终于找到点踪迹了,基本上搞定 查看原帖>>
收起
int x = 10; int y = 10; int width = 300; int height = 50; float[] outerR = new float[] { 12, 12, 0, 0, 0, 0, 30, 30 }; RoundRectShape rectShape=new RoundRectShape(outerR, null, null); ShapeDrawable mD...
全部展开
int x = 10; int y = 10; int width = 300; int height = 50; float[] outerR = new float[] { 12, 12, 0, 0, 0, 0, 30, 30 }; RoundRectShape rectShape=new RoundRectShape(outerR, null, null); ShapeDrawable mDrawables= new ShapeDrawable(new RoundRectShape(outerR, null,null)); mDrawables.getPaint().setColor(Color.RED); mDrawables.setBounds(x, y, x + width, y + height); mDrawables.draw(canvas);费了九牛二虎之力终于找到点踪迹了,基本上搞定
收起