Imageview上边圆角,下边直角
来源:互联网 发布:淘宝打不开店铺首页 编辑:程序博客网 时间:2024/03/29 12:46
public class RoundCornerImageView extends ImageView { private Paint mPaint; private Paint mPaint2; private int roundHeight = UIUtils.dip2px(20); private int roundWidth = UIUtils.dip2px(20); public RoundCornerImageView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } public RoundCornerImageView(Context context, AttributeSet attrs) { super(context, attrs); init(); } public RoundCornerImageView(Context context) { super(context); } private void init() { mPaint = new Paint(); mPaint.setColor(Color.WHITE); mPaint.setAntiAlias(true); //16种状态 mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_OUT)); mPaint2 = new Paint(); mPaint2.setXfermode(null); } @Override public void onDraw(Canvas canvas) { Bitmap bitmap = Bitmap.createBitmap(getWidth(), getHeight(), Config.ARGB_8888); Canvas canvas2 = new Canvas(bitmap); super.onDraw(canvas2); drawLeftUp(canvas2); drawRightUp(canvas2);// drawLeftDown(canvas2);// drawRightDown(canvas2); canvas.drawBitmap(bitmap, 0, 0, mPaint2); bitmap.recycle(); } private void drawLeftUp(Canvas canvas) { Path path = new Path(); path.moveTo(0, roundHeight); path.lineTo(0, 0); path.lineTo(roundWidth, 0); //arcTo的第二个参数是以多少度为开始点,第三个参数-90度表示逆时针画弧,正数表示顺时针 path.arcTo(new RectF(0,0,roundWidth*2,roundHeight*2),-90,-90); path.close(); canvas.drawPath(path, mPaint); } private void drawLeftDown(Canvas canvas) { Path path = new Path(); path.moveTo(0, getHeight()-roundHeight); path.lineTo(0, getHeight()); path.lineTo(roundWidth, getHeight()); path.arcTo(new RectF(0,getHeight()-roundHeight*2,0+roundWidth*2,getHeight()),90,90); path.close(); canvas.drawPath(path, mPaint); } private void drawRightDown(Canvas canvas) { Path path = new Path(); path.moveTo(getWidth()-roundWidth, getHeight()); path.lineTo(getWidth(), getHeight()); path.lineTo(getWidth(), getHeight()-roundHeight); path.arcTo(new RectF(getWidth()-roundWidth*2,getHeight()-roundHeight*2,getWidth(),getHeight()), 0, 90); path.close(); canvas.drawPath(path, mPaint); } private void drawRightUp(Canvas canvas) { Path path = new Path(); path.moveTo(getWidth(), roundHeight); path.lineTo(getWidth(), 0); path.lineTo(getWidth()-roundWidth, 0); path.arcTo(new RectF(getWidth()-roundWidth*2,0,getWidth(),0+roundHeight*2),-90,90); path.close(); canvas.drawPath(path, mPaint); }}
阅读全文
0 0
- Imageview上边圆角,下边直角
- android上面圆角,下面直角 ImageView
- Android 自定义上面圆角下面直角的ImageView
- Android实现Imageview上面圆角下面直角效果
- android ImageView实现上面圆角下面直角(xml实现方法)
- android ImageView实现上面圆角下面直角(自定义view实现)
- 安卓imageview实现上面两个圆角下面两个直角的效果
- 上边一个颜色下边一个颜色
- android 上边标题下边图片的button
- 直角多边形添加圆角
- asp 表格定位 去掉上边距和下边距
- 去掉listview的上边和下边有黑色的阴影
- listview的上边和下边有黑色的阴影
- Cell上边或者下边出现不规则长度的黑色细线
- 上边的UITableViewCell覆盖下边的UITableViewCell的问题
- 对cell的最上边和最下边左圆角处理
- div左边固定、右边自适应 和 上边固定、下边自适应
- 自定义图片在上边,文字在下边的按钮
- JavaWeb的一些基础知识(八) ----- woff字体
- 用adb往手机上装软件
- PHP获取当前文件的绝对路径
- 腾讯祭出大招VasSonic,让你的H5页面首屏秒开!
- 原来天猫双11不止可以买买买,还可以这样玩玩玩!
- Imageview上边圆角,下边直角
- 如何一键将 Sketch 转换成 PSD 源文件
- Spring应用(一)
- 微信请求工具类
- opencv2413+VS2013静态编译
- 文字高度的适配
- Linux下使用ps命令来查看Oracle相关的进程
- [Tensorflow] Session.run、model保存和optimizer优化器
- RSA破解作业