Paint myPaint = new Paint();
myPaint.setColor(Color.GREEN);
myPaint.setStyle(Paint.Style.STROKE);
canvas.drawRect(
getLeft()+(getRight()-getLeft())/4,
getTop()+(getBottom()-getTop())/4,
getRight()-(getRight()-getLeft())/4,
getBottom()-(getBottom()-getTop())/3,myPaint);
我的结果
最佳答案
我正在使用9补丁图像绘制此图像。
Bitmap b= BitmapFactory.decodeResource(getResources(), R.drawable.bg_scanner_frame);
paint.setColor(Color.RED);
canvas.drawBitmap(b, width/2-b.getWidth()/2, height/2-b.getHeight()/2, paint);