I am trying to create a tiled background for the match_parent -wide container, where the fragment repeats from the parent center, and not from its left edge. I want this so that the background is always displayed in the center regardless of the width of the screen.
I noticed that Android BitmapDrawable has a gravity attribute, but it doesn't seem to work if tileMode set to repeat or mirror . I would suggest that the bitmap is first centered in the container and then repeats outward from the center point. Instead, it is still left-aligned and then repeated, with the result that the first tile will always be fully visible, but the last fragment will be cropped if the screen width is not a multiple of the tile width.
UPDATE: Just noticed: "Gravity is ignored when tile mode is on." (tileMode attr docs.) Any other ways to achieve this?
source share