If your outer rectangle is outerRect
and already contains the coordinates, you can set the borders of the inner rectangle relative to the border of outerRect
.
Rect innnerRect = new Rect(outerRect.left+5, outerRect.top+5, outerRect.right-5, outerRect.bottom-5);
Update:
You can also make the image available for 9 patches. Define the middle of the inner rectangular region as expandable.
source share