配售缩放控制在一个图形页面 [英] Placing Zoom Controls in a MapView

查看:95
本文介绍了配售缩放控制在一个图形页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让缩放控件显示在一个图形页面,如下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.

推荐答案

添加下面一行到你的图形页面<的的OnCreate()方法/ code>类:

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

view.setBuiltInZoomControls(真);

这篇关于配售缩放控制在一个图形页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆