The Android framework allow to create a drawable that wraps a bitmap and can be tiled, stretched, or aligned. First of all, we need the background pattern to use as background tile. The pattern can be any drawable located in the drawable directory of the application, for example :
Then we need to create the drawable that wraps our pattern.
The tileMode attribute defines the way the pattern is repeated :
-
disabled
- Do not tile the bitmap. This is the default value. clamp
- Replicates the edge color. repeat
- Repeats the bitmap in both direction. mirror
- Repeats the shader’s image horizontally and vertically, alternating mirror images so that adjacent images always seam.