配售缩放控制在一个图形页面缩放、图形、页面

由网友(______薄暮涼年)分享简介:我试图让缩放控件显示在一个图形页面,如下code几乎工作,但缩放控件显示在图形页面,而不是底部中间左上方像我specifiying通过setGravity()。可有人开导我,给我缺少的是什么?I'm trying to get the zoom controls to show up in a mapview, th...

我试图让缩放控件显示在一个图形页面,如下code几乎工作,但缩放控件显示在图形页面,而不是底部中间左上方像我specifiying通过setGravity()。可有人开导我,给我缺少的是什么?

I'm trying to get the zoom controls to show up in a mapview, the following code almost works, but the zoom controls appear in the top left of the mapview, not the bottom center like I'm specifiying via setGravity(). Can someone enlighten me as to what I'm missing?

zoomView = (LinearLayout) mapView.getZoomControls();

zoomView.setLayoutParams(new ViewGroup.LayoutParams
  (ViewGroup.LayoutParams.WRAP_CONTENT,
   ViewGroup.LayoutParams.WRAP_CONTENT)); 

zoomView.setGravity(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL);
mapView.addView(zoomView);

这些意见/布局都是编程方式建造,没有布局文件来调整。

These views/layouts are all constructed programatically, there is no layout file to tweak.

推荐答案

添加下面一行到你的图形页面类:

Add the following line to the OnCreate() method of your MapView Class:

view.setBuiltInZoomControls(真);