自定义地图标记和自定义背景
我试图让图像具有透明背景,这样地图就不会被带有图像的方形标记遮挡。我应该使用什么图像编辑器和什么设置才能使其正常工作?
我正在尝试为按钮做一些自定义背景,但出现了同样的问题:我得到了方角和不随按钮缩放的背景。
我认为这都是同一个问题的一部分:我没有使用正确的工具和正确的设置来创建图像。我一定是误解了有关图像周围的白色边框以及可扩展按钮背景的顶部和左侧的黑线的文档和示例。
以下是重现该问题的快速方法:
按照以下说明创建 MapView 程序: http://developer.android.com/resources/tutorials/views/ hello-mapview.html
对于图标,我首先使用从页面复制的图像:
接下来我在 Microsoft Paint 中编辑图片,并剪掉小家伙的触角。我并不残忍,在那个实验中没有真正的机器人受到伤害。我用像素厚的白色边框围绕新图片,从图像其余部分周围的边框复制,然后复制边框外图像空白区域中的黑色。
我将图像保存为 myandroid.png 并将文件复制到布局文件夹中。将活动指向新图片并运行程序。
该图像以完整的方形背景和阴影显示,而不是使用原始图像时存在的机器人形状的图像和阴影。
自定义按钮背景: 请按照以下位置的相对布局示例的说明进行操作: “http://developer.android.com/resources/tutorials/views /hello-relativelayout.html"
接下来,我创建了一个图像来展开作为名为 backbutton.png 的按钮的背景。根据我在第 298 页的“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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您使用MSPaint保存图像是否定义了透明颜色?
应该在图像>属性
You used MSPaint to save the image did you define the transparent color?
should in Image > Attributes
要为按钮和其他可以在运行时更改其大小的小部件创建自定义背景,您应该创建 NinePatch 图像。您应该使用的工具是 draw9patch 并且可用与Android SDK。
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.