I have an image which I’m using as a background for a RelativeLayout. The image needs to be tiled horizontally to make a pattern.
I’m able to get the image to tile horizontally by using this code:
BitmapDrawable b3 = (BitmapDrawable)getResources().getDrawable(R.drawable.background);
b3.setTileModeX(Shader.TileMode.REPEAT);
v.findViewById(R.id.layout).setBackgroundDrawable(b3);
The problem is that the image also tiles vertically. It seems to tile in the “clamp” mode in the vertical, but “repeat” mode in the horizontal. Here is a screenshot:

As you can see, the image is just a little bit smaller than the space it occupies, and the bottom edge is “clamped”.
How can I set the image to stretch vertically but tile horizontally?
This method invokes creation of new bitmap but it looks like it’s acrhiving your goal
Please note that it only works if view was already layouted, so a method lile
onWindowFocusChangedis a good place for this code.