有的时候显示效果不如意的时候,我们可以自己重写方法来达到想要的效果。
@Override
protected void onDraw(Canvas canvas)
{
super.onDraw(canvas);
Paint paint = new Paint();
// 将边框设为蓝色
paint.setColor(android.graphics.Color.BLUE);
//设置边线的宽度
paint.setStrokeWidth(5);
// 画TextView的4个边
canvas.drawLine(0, 0, this.getWidth() - 1, 0, paint);
canvas.drawLine(0, 0, 0, this.getHeight() - 1, paint);
canvas.drawLine(this.getWidth() - 1, 0, this.getWidth() - 1, this.getHeight() - 1, paint);
canvas.drawLine(0, this.getHeight() - 1, this.getWidth() - 1, this.getHeight() - 1, paint);
}
重写该方法,实现背景的重写。