你如何编程方式更改宽度和放大器;谷歌地图V2(支持片段)高度? [英] How do you programmatically change the width & height of Google Maps v2 (support Fragment)?
问题描述
您如何编程改变com.google.android.gms.maps.SupportMapFragment的宽度和高度?我想像你也许可以把它包起来与match_parent一个ViewGroup中,但我希望不要窝,如果我没有(诚实甚至不知道它的工作原理)。
How do you programatically change the width and height of a com.google.android.gms.maps.SupportMapFragment? I'd imagine you might be able to wrap it in a viewgroup with match_parent, but I'm hoping not to nest if I don't have to (honestly not even sure it works).
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/storefront_map"
class="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="250dp"
/>
要放弃背景下,我想从一个高度的地图扩大到其他地图上点击。
To give context, I'd like to expand the map from one height to another on map click.
mMap.setOnMapClickListener(new GoogleMap.OnMapClickListener() {
@Override
public void onMapClick(LatLng latLng) {
expandMap(); // not sure how to do this programatically.
}
});
任何帮助将是巨大的!
Any help would be great!
推荐答案
我理解了它在很大程度上与<一的帮助href="http://stackoverflow.com/questions/13833709/programmatically-set-google-map-fragment-visibility-api2?rq=1">Programmatically设置谷歌地图片段可见性(API2)。
I figured it out largely with the help of Programmatically set google map fragment visibility (API2).
mMapFragment = (SupportMapFragment) (getSupportFragmentManager()
.findFragmentById(R.id.storefront_map));
ViewGroup.LayoutParams params = mMapFragment.getView().getLayoutParams();
params.height = 900;
mMapFragment.getView().setLayoutParams(params);
这篇关于你如何编程方式更改宽度和放大器;谷歌地图V2(支持片段)高度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!