Custom Map markers and custom backgrounds - android

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.

You used MSPaint to save the image did you define the transparent color?
should in Image > Attributes

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.

Related

How do I create a layout w/ a white background, grey border with a triangle arrow - Android

How would I replicate this in Android, my general instinct would be to create a regular layout w/ a border, then have 2 layouts that contain a triangle (one the same color as the border + one that's slightly smaller but white and overlap the two), idk if there's an easier way to do that:
You can use 9patch to achieve something like you wanted.
The Draw 9-patch tool is a WYSIWYG editor that allows you to create
bitmap images that automatically resize to accommodate the contents of
the view and the size of the screen. Selected parts of the image are
scaled horizontally or vertically based indicators drawn within the
image.
A complete guideline can be found here : http://developer.android.com/tools/help/draw9patch.html
The easiest way to reach this, is to set the layout background to that image.
background="#drawable/template"
Probably you want to have the area out of the "bubble" transparent, so you will need to save it as PNG.

How to make this type of drawable in xml

I want to make a transparent circle in center of screen and an opaque are on rest of screen. Is this possible with drawable? Or can it be done programmatically.
I have added an image on top of map. Map works perfectly. But problem is I want to support multiple resolutions so I don't want to use different images.
https://www.dropbox.com/sh/yyafqik996p4avp/AABc8ZMKi4pks_BQutQrbg8aa?dl=0
EDIT:
1)Map image is what is my expected output.
2)Mapfilter image is what i want to create using drawable or programmatically.
3)Output image is what i am getting while using below method.
I used this method to draw the second image
http://pastebin.com/MUrH8gmS
I set the output bitmap to my image view using setImageBitmap method
But now the problem is it leaves some space on left and right of image(See Output.png image). How to remove it?
You can use GroundOverlay.GroundOverlay to set the transparent circle image onto the center of the map.

set up different clickable part image android

Im working with android about image and onclick listener. The purpose of my app is to monitor the area that user clicks on the screen. For example, I have a picture containing a rectangular and a circle. Assume that the color of the whole picture is brown(wood). So when I click on the rectangular, the color of rectangle will change to yellow. When I click on the one part of the picture, the color of that part will change its color, but other parts do not change. So, Im thinking about the solution for this app. Do I have to cut this picture separately and put them into the screen by using relative review? Or is there any other way to do this(Set up a coordination system)?
Yes you have to cut this picture separately and put them into the screen by using relative review. For example two ImageView with your backgound.
You can slse the image as recommeded by the other post, or overlay the image with a RelitiveLayout with specific sized buttons (background = #android/color/transparent)

Android: how to use the 9patch creator?

I am trying to create a stretchable scroll handle for my app.
The first image is the scrollhandle.9.png that I include in my app's resources.
The second image shows what this 9patch image looks like when used in my app.
Any advice on how to accomplish a stretchable scroll handle?
Edit: With help from posters, I was able to get an image that works. I added it below to help those who may find this in the future.
The area covered by the top and the left black line(dots) will be used while scaling your image. This area will be highlighted to you when you click the "show patch" option. You can see how the image scales by using the "Patch scale" option given in the draw9patch tool.
The area covered by the right and bottom lines(dots) will hold the content for the background.
Eg: You can define boundaries for the text inside 9 patch image for editor background. For your case you don't need right and bottom lines.
So for your case place two dots at the top corner and two dots at the left corner. Make sure patches doesn't fall in the arrow image of the scroll(if they do fall your arrow image will also get stretched) . Try putting the dots only in the left and top lines till you get the desired preview with "Patch scale" option.
If you use only one dot (instead of four) at the top and bottom left, and one at image top center, it should stretch the way you want it to.

Draw 9-patch not working - cannot edit image

after I found out (sadly) that there is no easy way to create a simple border around a View, I was forced to use the 9-patch-image approach to get a border around my View.
So I read the short thing there is on the 9-patch and its easy enough to understand. I started the "Draw 9-patch" application that came with the Android SDK, opened up a very simple image I created in Paint and then... I got stuck.
According to the page (http://developer.android.com/guide/developing/tools/draw9patch.html) I should be able to define those areas where the image can be expanded and so on, just by clicking on the edges ("Click within the 1-pixel perimeter to draw the lines that define the stretchable patches...").
So I try to do just that and absolutely nothing happens. I try to hold down SHIFT when clicking and also do the rigth-mouse-click, and nothing happens. When I move the mouse away from the 1-pixel perimiter I get a grey-and-red "marquee" (stripes).
Bottom line is: nothing happens no matter what I do.
The tool definitely works, but make sure the image you create first does NOT have the .9.png extension. If it does, the draw9patch tool will assume the 1 pixel perimeter of your image is already setup as 9-patch. If you open an image with just a .png extension, the tool will add the 1 pixel perimeter and you will be able to manipulate it as described, and save it as 9-patch when you're done.
The 9-patch tool is a bit awkward to use, but it does work. I believe you need to left click and drag around the edge to paint the outside border.
Alternatively, you can use any image editor and create a one pixel empty border around it, and draw in the following:
Top/Left = black pixels for the area of the image that can be grown or shrunk as needed. For a typical border, it is everything except for the curved corners
Bottom/Right = black pixels for the small snippet that should be repeated if the image needs to be grown in that direction.
You must use a non-8bit png file to create a .9.png file, or it can not be edit.
In my case, I can convert a 8-bit png to 9-patch file with Android Studio successfully, but I can't edit it anyway.
When I export the origin psd to normal png file, and convert it to 9-patch file, the 9-patch borders ban be edit now!

Categories

Resources