views:

213

answers:

1

I want to set a specific background image for all my buttons.

So, I changed my PNG file into a Ninepatch drawable using the "draw9patch" tool(by specifying the line of strecth).

Then, I applied this as background to my button using "myBtn.setBackgroundResource(R.drawable.new_png);"

Now, the background appears for the button, but the lines of stretch are also visible on the android screen, wherever I'd specified them in the tool.

Can you help? Is there something wrong in how I'm using the tool?

+3  A: 

Ninepatch png files must be named with a special naming convention: for instance in your example, new_png.9.png. When you refer to the drawable in your code, you exclude the '.9.png', so your code would not need to change, only the image file name needs to change.

dhaag23
Hey thanks a lot...I had foolishly been renaming the file to remove the .9 extension...
kiki