I’ve run into this particular issue several times now. It’s a bug in the Android SDK, which apparently has been fixed as of ICS (Ice Cream Sandwich). When you place a <bitmap> inside a <layer-list>, it tends to do whatever it feels like doing in regards to repeating the bitmap. Sometimes it will follow your instructions, and sometimes it won’t.
To fix this, just set the repeat mode in code. Here’s a snippet that will set all your Bitmaps repeating in a LayerDrawable.
private void setLayerDrawableBitmapsRepeating(LayerDrawable layerDrawable) {
final int size = layerDrawable.getNumberOfLayers();
for(int i = 0; i < size; i++) {
Drawable drawable = layerDrawable.getDrawable(i);
if(drawable instanceof BitmapDrawable) {
((BitmapDrawable) drawable).setTileModeXY(TileMode.REPEAT, TileMode.REPEAT);
}
}
}
final int size = layerDrawable.getNumberOfLayers();
for(int i = 0; i < size; i++) {
Drawable drawable = layerDrawable.getDrawable(i);
if(drawable instanceof BitmapDrawable) {
((BitmapDrawable) drawable).setTileModeXY(TileMode.REPEAT, TileMode.REPEAT);
}
}
}