Android 画布与图像

发布于 2024-11-10 02:33:00 字数 275 浏览 0 评论 0原文

我有一个白色半透明的背景图像。它用作文本容器,以便您可以区分背景图像和文本。

目前我使用的图像是带有圆角的白色矩形,但是当然,当在不同的屏幕尺寸上使用它时,图像会扭曲,但不是很大或很明显,但是用画布绘制这个图像会更好或可能吗?

如果可能的话,它会大大减慢应用程序的速度吗?

更新:

谢谢@jkhouw1 我已经研究了 9 个补丁图像,这似乎非常合适。我仍然有兴趣了解画布相对于图像的好处,但如果您发布一些内容作为答案,我会接受它。谢谢。

I have a background image that is white and semi-transparent. This is used as a text container so you can differentiate between the background image and text.

Currently I am using an image that is a white rectangle with rounded corners, but of course when using this on different screen sizes the image is distorted, not massively or that noticeably, but would it be better or possible to draw this image with a canvas?

If it is possible would it slow down the app considerably?

UPDATE:

Thank you @jkhouw1 I have looked into 9 patch images and this seems very suitable. I am still interested in knowing the benefit of canvas against images, but if you post something as an answer I will accept it. Thank you.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

思念绕指尖 2024-11-17 02:33:00

还没有尝试过,但我认为通过定义

Haven't tried this yet, but I think this should be possible by defining a shape drawable. You can define round corners and you can make it semi-transparent by defining the color with alpha-value, for example #80FF0000 should be semi-transparent red.
I assume this would be a good solution both in terms of compatibility and performance.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文