How to make MapView object transparent (alpha)?

不羁岁月 提交于 2019-12-01 12:42:08

问题


All,

I have a need to display information on a MapView object. No problems there.

The issue is that there are times when the MapView object displays map details that visually compete with my overlay data.

So, what I'd like to do is provide a way to "scale back" the MapView object visually by using an alpha channel.

Can an alpha value get applied to a MapView object? If so, how?

Alternatively, I was thinking that perhaps a separate all black overlay might provide the same results. Scale the alpha of this overlay and I might end up with the same overall effect.

Insight please.

Thanks.

Rich


回答1:


Are you sure you want to do this? It might be better to revisit your overlay's graphic design... simply giving them a thicker border might be a cheap solution to the problem.

First suggestion would be to subclass MapView and override dispatchDraw() with something like this:

@Override protected void dispatchDraw(Canvas canvas) {

  // Firstly let MapView draw
  super.dispatchDraw(canvas);

  // Draw a translucent fill on top of it
  canvas.drawColor(0x7FFFFFFF);

  // TODO: Draw my overlay
}


来源:https://stackoverflow.com/questions/3979405/how-to-make-mapview-object-transparent-alpha

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!