int radious = 32; Paint paint = new Paint(); // lefttop,lefttop,righttop,righttop,leftbottom,leftbottom,rightbottom,rightbottom float[] radiusArray = { radious, radious, radious, radious, radious, radious, radious, radious }; private void badgeWithDrawable(Canvas target, Drawable badge) { int badgeSize = mContext.getResources().getDimensionPixelSize(R.dimen.profile_badge_size); Path path = new Path(); //先绘制剪切保证后面绘制图案在clip内,超出的图片自动被裁剪 RectF rect = new RectF(0, 0, mIconBitmapSize, mIconBitmapSize); path.addRoundRect(rect, radiusArray, Path.Direction.CW); target.clipPath(path); badge.setBounds(mIconBitmapSize - badgeSize, mIconBitmapSize - badgeSize, mIconBitmapSize, mIconBitmapSize); badge.draw(target); }
android 分别修改bitmap四个角圆角大小
最新推荐文章于 2024-04-09 06:34:27 发布