I’m having quite a hard time with a textured background. I have a 60px by 60px bitmap texture that I want to set as the background for my layout in a repeated tile pattern. Here’s the layout xml located in res/layout:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/dark_texture_background" >
...
</RelativeLayout
And here is the dark_texture_background, located in res/drawable:
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/dark_background_texture"
android:tileMode="repeat" />
The dark_background_texture is the 60×60 pixel image.
So, the issue is that the texture image is being enlarged while also being tiled. I added a red line to the outside of the texture image to see exactly where the texture images were, and here’s the result:

I also added the screen height, width and density according to getResources().getDisplayMetrics().
Since the screen width is 480 pixels, the texture image should be repeated 8 times across (480 / 60 = 8). Instead, there are only 5 ~1/4. The image is now ~90 pixels and tiled. WTF?
Why is my texture image being stretched when I explicitly tell it to repeat?
I’m not sure what Raghav’s referring to with the bug, exactly, but if they’ve changed something in ICS+ then there was certainly something wrong. That said, I’m fairly certain that bitmap images in
drawableare assumed to bemdpi, and scaled from there (maybe they changed that behavior?), which makes sense given that your 60px image became 90px (60 * 1.5 scaling factor).You can avoid scaling altogether, keeping in mind that the physical size will differ on different densities (although for a tiled background it’s probably not important), by placing your bitmaps into a
drawable-nodpifolder only. Android will use those drawables without scaling, regardless of density.