The key to correctly stretching is in the top and left border.
The top border controls horizontal stretching and the left border controls vertical stretching.
This example creates rounded corners suitable for a Toast.
The parts of the image that are below the top border and to the right of the left border will expand to fill all unused space.
This example will stretch to all combinations of sizes, as shown below: