Android has an interesting solution to this called 9-patch-files [1]. They basically add a 1px-margin around the image. By coloring the margin in different colors, you tell the OS what areas to stretch and what should be kept as-is based on the screen size.
[1] https://developer.android.com/studio/write/draw9patch