丑陋的图像、渲染问题和多屏幕支持

发布于 2024-12-10 12:41:44 字数 669 浏览 0 评论 0原文

我有一个列表视图,列表视图中的各个项目都是从自定义布局中夸大的。我对此没有任何问题。我的问题是,当我为该项目添加背景时,它显得非常奇怪,就像重新调整了大小并且看起来很丑:

在此处输入图像描述 在此处输入图像描述

我为项目的高度设置了不同的值,例如wrap_content,就像真实图像的确切高度一样px,我尝试了倾角中的值,但没有任何帮助。原始图像还可以,它看起来就像它应该的那样,但是当我将它作为该项目的背景时,它看起来很难看。这不是我第一次经历这样的事情。有时放置wrap_content 有帮助,但并不总是如此。我不明白问题的背景为什么会发生这种情况?

为什么有时当我把一些图像作为背景甚至有一些渐变等时,它工作得很好,为什么有时却不能呢?

我有过这样的经历:我有带背景的线性布局,当布局的大小是wrap_content,比如说77dip时,它看起来非常丑陋(中间有划痕),当我放置78或76dip高度时,背景看起来非常漂亮,再次在73 浸去所示中间器皿中的划痕。我永远不明白这种奇怪的行为,有人可以澄清这一点以及做这样的事情的最佳实践是什么。

我读过多屏幕支持,但我从未遇到过此类问题的解决方案,我什至从未读到其他人经历过类似的事情。

I have an listview and the individual items in the listview are inflated from custom layout. I do not have any problem with that. My problem is when I put a background to the item, it is rendered very strange, it is like re-sized and and it looks ugly:

enter image description here
enter image description here

I put different values for the height of the item like wrap_content, like the exact height of the real image in px, I tried values in dip but nothing helps. The original image it is ok, it looks just like it should but when I put it as background for the item it looks ugly. This is not first time I experience something like this. Somethimes putting wrap_content helps but not always. I do not understand the background of the problem why is this happening?

Why sometimes when I put some image as background even have some gradients and so on, it works just perfectly and why sometimes it don't?

I had experience where I had linear layout with background and when the size of the layout was wrap_content of let say 77dip it looked very ugly (with scratches in the middle) and when I put 78 or 76dip height the background looked very nice, again on 73dip the scratches in the middle ware shown. I never understand this strange behavior, can someone please clarify this and what is the best practice for doing things like this.

I read multiple screen support but I never meet solution for this kind of problem I never even read that someone else have experienced something like this.

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

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

发布评论

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

评论(2

丶情人眼里出诗心の 2024-12-17 12:41:44

我认为您遇到了条带/抖动问题。

问题的根源在于屏幕无法匹配您确切想要的颜色,并将其“舍入”到最接近的可能值。这可能会在具有渐进颜色(例如渐变)的图像中产生不良结果。

请参阅此链接:
http://www.curious-creature。 org/2010/12/08/bitmap-quality-banding-and-dithering/

启用抖动应该会对您有所帮助。

I think you're getting into banding/dithering problems.

The origin of the problem is that the screen can't match the colour you exactly want and will "round" it to the nearest possible value. This might yield bad results in images with progressive colours like gradients.

See this link:
http://www.curious-creature.org/2010/12/08/bitmap-quality-banding-and-dithering/

Enabling dithering should help you.

日裸衫吸 2024-12-17 12:41:44

使用9-patch工具创建可扩展的9-patch图像。一旦您使用它创建图像,它将支持所有屏幕分辨率,并且在每种分辨率下看起来大多相同。

有关9 块图像内的可拉伸块

很好的教程,有很好的例子: http://android10.org/ index.php/articlesother/279-draw-9-patch-tutorial

Use 9-patch tool to create scalable 9-patch image. Once you create image using this, it will support all the screen resolutions and mostly looks same in every resolutions.

More information about stretchable patches inside the 9-patch image.

Nice tutorial with great examples: http://android10.org/index.php/articlesother/279-draw-9-patch-tutorial

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