@SuppressLint("NewApi")
private void init(AttributeSet attrs) {
if (Build.VERSION.SDK_INT >= 11) {
setLayerType( LAYER_TYPE_SOFTWARE, null );
}
borderColor = DEFAULT_BORDER_COLOR;
if(attrs != null){
TypedArray array = context.obtainStyledAttributes(attrs, R.styleable._RoundedImageView);
if(array != null){
borderColor = array.getColor(R.styleable._RoundedImageView_borderColor, DEFAULT_BORDER_COLOR);
borderWidth = array.getDimensionPixelSize(R.styleable._RoundedImageView_borderWidth, -1);
roundWidth = array.getDimensionPixelSize(R.styleable._RoundedImageView_roundWidth, -1);
array.recycle();
}
}
DisplayMetrics displayMetrics = new DisplayMetrics();
WindowManager windowManager = (WindowManager) getContext().getSystemService( Context.WINDOW_SERVICE );
windowManager.getDefaultDisplay().getMetrics( displayMetrics );
paint = new Paint();
paint.setStyle( Style.STROKE );
paint.setColor( borderColor );
paint.setAntiAlias( true );
paint.setStrokeWidth( borderWidth );
Xfermode xfermode = new PorterDuffXfermode( PorterDuff.Mode.SRC );
paint.setXfermode( xfermode );
drawRect = new RectF();
drawPath = new Path();
}
RoundedImageView.java 文件源码
java
阅读 48
收藏 0
点赞 0
评论 0
项目:RoundedImageView
作者:
评论列表
文章目录