android - Tiled drawable sometimes stretches -
i have listview items have tiled background. accomplish this, use following drawable xml:
<bitmap xmlns:android="http://schemas.android.com/apk/res/android" android:src="@drawable/tile" android:tilemode="repeat" />
usually, works. sometimes, however, src drawable isn't tiled, stretched fill entire list item. (i've got several different tiles this, , use them mixed in 1 listview. if there stretching instead of tiling, it's never been in of them @ once, that's worth.)
i tried add android:dither="true"
xml, since read somewhere without there might bugs. didn't change anything.
has had same problem? how did fix it?
i got bitten problem. hard diagnose, harder find similar reports , usable solutions.
"tapas" on freenode #android-dev irc channel came following utility method:
public static void fixbackgroundrepeat(view view) { drawable bg = view.getbackground(); if (bg != null) { if (bg instanceof bitmapdrawable) { bitmapdrawable bmp = (bitmapdrawable) bg; bmp.mutate(); // make sure aren't sharing state anymore bmp.settilemodexy(tilemode.repeat, tilemode.repeat); } } }
apply views have tiled background set (e.g. findviewbyid them).
also, have impression bug started acting after setting "anydensity=true" in androidmanifest.xml
Comments
Post a Comment