views:

356

answers:

2

I am trying to get the images to have transparent backgrounds so the map is not blocked by a square marker with an image in it. What image editor and what settings should I use to get this to work?

I am trying to do some custom backgrounds for buttons and the same problem comes up: I get square corners and a background that does not scale with the buttons.

I think this all part of the same problem: I am not using the right tool with the right settings to create the images. I must be misinterpreting the documentation and examples that talk about a white border around the image and a black line along the top and left side for the expandable button background.

Here's a quick way to reproduce the problem:

Follow the directions to create the MapView program as described on: http://developer.android.com/resources/tutorials/views/hello-mapview.html

For the icon I first used the image copied from the page:

Next I edited the picture in Microsoft Paint, and cut off the little guy's antennae. I'm not cruel and no real androids were harmed in that experiment. I surrounded the new picture with a pixel thick border of white, copied from the border that was around the rest of the image, and then copied the black that was there as well in the void areas of the image, outside the border.

I saved the image as myandroid.png and copied the file to the layout folder. Pointed the activity to the new pic and ran the program.

The image was displayed with a full square background and shadow, not the android shaped image and shadow that was there when the original image was used.

Custom Button background: Follow the directions for the Relative Layout example at: "http://developer.android.com/resources/tutorials/views/hello-relativelayout.html"

Next, I created an image to expand as a background for the button called backbutton.png. It too is surrounded by a white border and black filled on the corners, the top and one side per documentation I found in "Android Programming Tutorials" on page 298.

The background does not expand, nor do the corners round.

I wish I could show you screenies of what I have.

How do you create the images for the custom backgrounds and the images for the custom map markers and buttons? I need to know what image editor to use and the file attributes to set, so the images expand and display with the proper void spaces in them.

Thank you in advance.

A: 

You used MSPaint to save the image did you define the transparent color?

should in Image > Attributes

Christopher
A: 

To create custom backgrounds for buttons and other widgets that can change their size at runtime, you should create NinePatch images. The tool you should use is draw9patch and is available with the Android SDK.

kaciula