How to make MapView object transparent (alpha)?

2019-02-20 23:50发布

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条回答
狗以群分
2楼-- · 2019-02-21 00:02

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
}
查看更多
登录 后发表回答