hasiertxo
hasiertxo

Reputation: 263

White line when applying 9-patch

I've got a problem with a 9-patch when used as a background. I add an image to clarify it.

Image:

enter image description here

This is the 9-patch:

enter image description here

Why is that white line there?

Upvotes: 0

Views: 375

Answers (1)

Kevin Coppock
Kevin Coppock

Reputation: 134664

Okay, well firstly, you have more stretch pixels than you need. It's not the cause of your problem but you only need one black pixel on the top and left. Secondly, you should be defining your content area to entail only the white area (as shown below). Lastly, I believe your problem is that Android is scaling your graphic. Do you have your 9-patch in the appropriate density folder? (i.e. if you're on an XHDPI device, is the 9-patch in drawable-xhdpi?). One thing you can do to avoid scaling altogether is to place your 9-patch in res/drawable-nodpi, but this will use the same graphic for all densities. This may or may not be what you need.

Here is a revised 9-patch that you should try along with the folder location suggestions above:

enter image description here

Upvotes: 1

Related Questions