在Android中绘制带有边框的填充矩形 [英] Drawing a filled rectangle with a border in android

查看:740
本文介绍了在Android中绘制带有边框的填充矩形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Android中有没有办法绘制带有黑色边框的填充矩形.我的问题是canvas.draw()接受一个绘画对象,据我所知,绘画对象的填充和笔触不能有不同的颜色.有办法解决吗?

Is there any way in Android to draw a filled rectangle with say a black border. My problem is that the canvas.draw() takes one paint object, and to my knowledge the paint object can't have a different color for the fill and the stroke. Is there a way around this?

推荐答案

您绘制一个具有边框颜色和矩形大小加上边框大小的矩形,更改油漆的颜色,然后使用正常大小.

You draw a rectangle with the color of the border and the size of the rectangle plus the border, you change the color of the paint and draw again the rectangle with the normal size.

这篇关于在Android中绘制带有边框的填充矩形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆