给ImageView添加边框
来源:互联网 发布:002174游族网络论坛 编辑:程序博客网 时间:2024/05/15 06:52
import android.content.Context;import android.graphics.Canvas;import android.graphics.Color;import android.graphics.Paint;import android.graphics.Rect;import android.util.AttributeSet;import android.util.Log;import android.widget.ImageView;public class MyImageView extends ImageView {private int color;public MyImageView(Context context, AttributeSet attrs) {super(context, attrs);color = Color.parseColor("#aaeeee00");// color=Color.parseColor(attrs.getAttributeValue(namespace,// "BorderColor"));}@Overrideprotected void onDraw(Canvas canvas) {super.onDraw(canvas);// 画边框Rect rec = canvas.getClipBounds();String TAG = null;Paint paint = new Paint();paint.setColor(color);paint.setStyle(Paint.Style.STROKE);paint.setStrokeWidth(10);canvas.drawRect(rec, paint);}}</span>
<span style="font-size:18px;"><?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:padding="20dp" > <com.example.sdsd.MyImageView android:id="@+id/image" android:layout_width="200dp" android:layout_height="200dp" android:layout_gravity="center" android:scaleType="center" android:src="@drawable/ic_a" > </com.example.sdsd.MyImageView> <!-- android:scaleType="centerCrop" --></LinearLayout></span>
0 0
- 给ImageView添加边框
- 给imageview,textview,button等添加边框
- Swift - 给图片(imageView)添加阴影边框
- android ImageView 添加边框
- ImageView添加选中边框
- imageView添加阴影和边框
- imageview添加阴影边框+圆角
- 给TextView添加边框
- 给UIView 添加边框
- 给Button添加边框
- 给UILabel添加边框
- 给QDockWidget添加边框
- 给ImageView添加点击事件
- 给Div添加边框颜色
- android给图片添加边框
- [Android] 给 Linearlayout 添加边框
- IOS给UIImage添加边框
- 给view添加虚线边框
- java随堂笔记
- 图像质量评价
- PHP获取搜索引擎关键字来源的函数(支持百度和谷歌等搜索引擎)
- 常用排序算法
- [07]scanf函数、printf函数
- 给ImageView添加边框
- 随堂笔记
- 用php处理百万级以上的数据提高查询速度的方法
- Java线程池之FutureTask【Java线程池系列3】
- 为ActiveX控件增加安全认证
- D3DXCreateTextureFromFileEx的应用
- 随堂笔记
- 回溯算法
- 使用Volley请求,获取POST请求cookie值