android ImageView 添加边框
来源:互联网 发布:mac怎么新建html文件 编辑:程序博客网 时间:2024/04/29 05:48
有两种方法可以给ImageView添加边框,一种是通过xml文件配置shape.另一种是重写ImageView的ondraw方法,这里用第二中方法:
package org.example.image.widgets;import android.content.Context;import android.graphics.Canvas;import android.graphics.Paint;import android.graphics.Rect;import android.widget.ImageView;public class MyImageView extends ImageView {// 边框颜色private int borderColor;// 边框宽度private int borderWidth;public MyImageView(Context context) {super(context);}// 设置边框颜色public void setBorderColor(int borderColor) {this.borderColor = borderColor;}// 设置边框宽度public void setBorderWidth(int borderWidth) {this.borderWidth = borderWidth;}// 重写绘图方法@Overrideprotected void onDraw(Canvas canvas) {super.onDraw(canvas);// 画边框Rect rect = canvas.getClipBounds();rect.bottom--;rect.right--;Paint paint = new Paint();paint.setColor(borderColor);paint.setStyle(Paint.Style.STROKE);paint.setStrokeWidth(borderWidth);canvas.drawRect(rect, paint);}}
- android ImageView 添加边框
- 给ImageView添加边框
- ImageView添加选中边框
- Android使用自定义ImageView为图片添加边框
- Android 简单实现圆形ImageView添加双层圆形边框
- Android ImageView 加边框
- Android ImageView加边框
- android Imageview去除边框
- Android ImageView设置边框
- imageView添加阴影和边框
- imageview添加阴影边框+圆角
- Android - ImageView 加边框 实例
- Android兑现ImageView加边框
- 给imageview,textview,button等添加边框
- android添加边框
- android 添加linearlayout 边框
- android 控件添加边框
- imageview 边框
- poj1256(STL--next_permunation)
- c语言有关字符的函数
- 网络运营之剑—html框架
- 坐标公式
- 扫描U盘里的所有文件的路径
- android ImageView 添加边框
- unix/linux/fedora 远程连接windows桌面--rdesktop
- 求助安装linux系统
- 记录远程登录地址批处理
- Apache Nutch 1.3 学习笔记一
- .NET Framework 数据提供程序
- Google AdMob Ads iOS Fundamentals
- 【矩阵优化连通性状压dp】哈密尔顿路径
- css常用设置