调整实际图形页面 - 在图形页面内容不 [英] Resizing Actual MapView - not contents in mapview

查看:112
本文介绍了调整实际图形页面 - 在图形页面内容不的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想调整我的图形页面,当用户点击某个按钮!(即 - 从图形页面进入屏幕尺寸全屏大小的四分之一),但是我不知道该怎么做。

I'm trying to resize my MapView when a user clicks a certain button (ie - go from a mapview a quarter of the screen size to full screen size) however I do not know how to do it!

我试过 mMapView.setLayoutParams(新MapView.LayoutParams(250,250,0,0,6)); ,但只给了我错误(抛出ClassCastException)

I've tried mMapView.setLayoutParams(new MapView.LayoutParams(250, 250, 0, 0, 6)); but that only gives me errors (ClassCastException).

我想不出别的(和搜索还没有拿出多少)。

I can't think of anything else (and searching has not come up with much).

推荐答案

试试这个:

        MapView map = new MapView(this, "");
        map.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
        map.setLayoutParams(new ViewGroup.LayoutParams(200, 200));

顺便说一句作为一般规则,从来没有使用绝对定位(250像素)做Android中任何东西 - 在不同设备上使用时,它会导致问题。使用相对布局,或至少是与设备无关的像素(DIP)。因此,例如,可以设置layout_width为wrap_content,的MapView的为1 layout_weight(因此它stetches以填充可用空间),然后将另一UI元素到其侧面,占用一些空间,并且在地图上会然后减小尺寸。

By the way as a general rule, never use absolute positioning (250 pixels) to do anything in Android - it'll cause problems when used on different devices. Use relative layouts, or at the very least device independent pixels (dip). So for example you could set the layout_width to wrap_content, the layout_weight of the MapView to 1 (so it stetches to fill the available space), and then place another UI element to its side, taking up some of the space, and the map will then reduce in size.

这篇关于调整实际图形页面 - 在图形页面内容不的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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