setMeasuredDimension(mWidth, mWidth); } } /** 1. 设置BitmapShader 2. 绘制 */ @Override protected void onDraw(Canvas canvas) { if (getDrawable() == null) { return; } setUpShader(); if (type == TYPE_ROUND) { canvas.drawRoundRect(mRoundRect, mBorderRadius, mBorderRadius, mBitmapPai...
bottomRightRadius, bottomRightRadius, bottomLeftRadius, bottomLeftRadius ) // 设置外边框矩形坐标 val borderRectF = RectF() borderRectF.set(left, top, right, bottom) // 设置外边框矩形路径 val borderPath = Path() borderPath.addRoundRect(borderRectF, radii, Path.Direction.CW) // 设置外边框画...
roundRectImageView.setRoundBorderRadius(100); ovalImageView.setType(XCRoundImageViewByXfermode.TYPE_OVAL); ovalImageView.setRoundBorderRadius(50); } } 七、照例,最后提供完整源码下载 真题园网:http://www.zhentiyuan.com 立即下载:http://download.csdn.net/detail/jczmdeveloper/8311659 个人简介: 软件研发...
在安卓开发中,如果你想在`ImageView`周围绘制边框,可以通过以下几种方法实现: ### 方法一:使用XML Drawable 1. **创建一个XML文件**(例如`border.xml`...
<solid android:color="@android:color/transparent" /> <stroke android:width="2dp" android:color="#FF0000" /> <corners android:radius="4dp" /> </shape> 应用背景: ```xml <ImageView android:id=”@+id/image_view_with_border” android:layout_width=”wrap_content” android:layout_height=”...
<corners android:radius="7dp" /> <padding android:top="5dp" android:right="5dp" android:bottom="5dp" android:left="5dp"/> </shape> </item> </layer-list> 效果图: 更多阅读:http://nodebook.info/book/view?bid=5354725719980e913e9be3f1 ...
private float mRoundRadius =0;// 矩形的圆角半径,默认为0,即直角矩形 private Paint mBorderPaint =newPaint(Paint.ANTI_ALIAS_FLAG); private RectF mViewRect =newRectF();// imageview的矩形区域 private RectF mBorderRect =newRectF();// 边框的矩形区域 ...
privateintmBorderWidth = DEFAULT_BORDER_WIDTH; privateBitmap mBitmap; privateBitmapShader mBitmapShader; privateintmBitmapWidth; privateintmBitmapHeight; privatefloatmDrawableRadius; privatefloatmBorderRadius; privatebooleanmReady; privatebooleanmSetupPending; ...
需要将本ImageView的宽值赋给矩形的right坐标,高赋值给bottom坐标即可borderRect.set(0,0, getWidth(), getHeight());//外圆的半径是算法(外圆所在矩形的宽和高这两边的短边的一半减去外圆到内圆的距离)borderRadius= Math.min((borderRect.width() -borderWidth) /2, (borderRect.height() -borderWidth)...
mRoundBorderRadius, mRoundBorderRadius, paint); }elseif(mType ==TYPE_OVAL ){//绘制椭圆canvas.drawOval(newRectF(0, 0, getWidth(), getHeight()), mPaint); }returnbitmap; } 3、在onDraw()中绘制出来 /*** 绘制view的内容*/@OverrideprotectedvoidonDraw(Canvas canvas) {//TODO Auto-generated...