Android - 如何绘制描边位图?
I have a bitmap like in the picture. I want to add a border for it using Canvas. Can anyone help me?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
I have a bitmap like in the picture. I want to add a border for it using Canvas. Can anyone help me?
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(2)
您可以使用 Paint.STYLE.STROKE 绘制边框。您需要进行两次单独的绘图调用。
You can draw a border using Paint.STYLE.STROKE. You need to do two separate calls to draw.
如果图像具有透明背景(png 文件)并且描边大小不太大,则可以仅绘制位图并对其应用 4 次颜色叠加 - 左、上、右和下。
If the image has a transparent background (png file) and the stroke size is not too large, you can just draw the bitmap with a color overlay applied to it 4 times -- left, top, right and bottom.