Usually when I need a background that changes to match the size of the content, I would use a nine-patch image.
I tried that for a graphic that was transparent except for a dashed outline with rounded corners. However, it ended up stretching the dashes, instead of repeating the pattern of dashes.
The image shows three lines:
1. The basic, small image
2. How the image looks when I stretch it
3. How the image should look

Is there a way to do this with a nine-patch image?
If not, what is the recommended alternative? I think it might be possible to use shapes and XML files to simulate it, but I’m not exactly sure how to do that or how to have the corners rounded.
And again, the reason why I don’t use a basic image is because this dashed outline would surround a box that may contain a little content or a lot.
You could create a canvas and then load the image on the canvas. To combat the problem with anti-aliasing, draw a rounded rectangle and mask it onto your image. When you draw the image, use the porter-duff Xfer mode of paint. You can control the stroke through paint as well, controlling the spacing and length of the lines just how you would like.