androidbordernine-patch

Incorrect stretching of simple 9-patch image to get 1px border on high-res devices


I want to get a simple 1px border with white background as 9-patch for a view in android application. It works fine on the Samsung Galaxy Tab 730, but to my suprise, the result on Samsung Nexus 10 is completely different:

Desired result (1px blue border and white background): Info Window with 9-patch background correctly displayed.

Actual result (1px blue border and light blue background): Info Window with 9-patch background and blue background (incorrectly stretched)

The used 9-patch is very simple: used 9-patch image, enlarged: enter image description here


Solution

  • Two solutions I found worked for me: