0

I am having trouble removing anti-aliasing on a 9-patch png and a normal drawable that is tiled to make a background. I am using the 9-patch as a background for my EditText controls and the tiled drawable is used as a background for an ImageView to create the 'divider'.

Here is some enlarged versions of my 9 patch png (it's hard to show white graphics so I filled in the transparent areas in blue):

9 patch

And my tiled background image along with the xml that defines the tiled pattern:

tile

<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
    android:src="@drawable/border_diagonal_lines"
    android:tileMode="repeat"
    />

Here is the whole thing put together:

app screenshot

The screenshot on the left is what I currently get and the screenshot on the right is what I want it to look like. What could I do to achieve the desired effect?

I also would like the imageview with the tiled background to always be 3 pixels tall regardless of screen resolution but using 'pixels' as units is generally a bad idea. Is there a way round this?

4

1 回答 1

1

它不是对您的图形进行抗锯齿,它可能是在缩放它们(当然,这也可能执行抗锯齿,但这不是原因)。您是否将它们放在正确的密度特定文件夹中?(例如drawable-hdpi,drawable-xhdpi等)如果您这样做,还要确保您没有android:anyDensity="true"在清单中使用该标签。

我还希望具有平铺背景的图像视图始终为 3 像素高,无论屏幕分辨率如何,但使用“像素”作为单位通常是个坏主意。有办法解决这个问题吗?

在一般情况下不鼓励这样做,当系统应该处理多个密度的缩放时(使用 DP 代替),但如果您特别需要 3 个像素高的东西,那么指定像素高度并没有什么“坏处”。

于 2012-07-25T16:46:21.163 回答