【问题标题】:How to re-size fragment and set to Google Map V2?如何重新调整片段大小并设置为 Google Map V2?
【发布时间】:2013-01-24 12:02:35
【问题描述】:

我正在尝试从以下answer 创建Facebook 之类的slider,我想在运行时更改地图宽度。

我在 bindComponent 方法中尝试过,但它对我不起作用..

ma​​p.xml

<?xml version="1.0" encoding="utf-8"?>

 <fragment xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/mapView"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        class="com.google.android.gms.maps.SupportMapFragment" />

活动

public class MapActivity extends FragmentActivity implements
     OnClickListener {


private ImageView mSlider;
LinearLayout.LayoutParams mapViewParameters;
GoogleMap gMap;
SupportMapFragment supportMap;
private DisplayMetrics metrics;


@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.slider);

    bindComponents();

}



private void bindComponents() {
    // TODO Auto-generated method stub

    supportMap = (SupportMapFragment) getSupportFragmentManager()
            .findFragmentById(R.id.mapView);

    metrics = new DisplayMetrics();

    mapViewParameters = (LinearLayout.LayoutParams) findViewById(
            R.id.mapView).getLayoutParams();
    mapViewParameters.width = metrics.widthPixels;
    findViewById(R.id.mapView).setLayoutParams(mapViewParameters);

    // Map
    gMap = supportMap.getMap();
    gMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);

    mSlider = (ImageView) findViewById(R.id.msliderImage);




}
  }

任何帮助将不胜感激。

【问题讨论】:

  • 据我所知,问题与调整地图宽度的 bindComponents() 有关

标签: android android-maps-v2


【解决方案1】:

我建议您查看this 库。我认为这是我在网络上见过的最好的实现 Facebook 之类的滑动菜单

【讨论】:

  • @Mitesh Agrawal 是的,我是……我的答案是一样的。您使用的组件肯定不是最好的,所以我建议您更改它。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2013-07-18
  • 1970-01-01
  • 1970-01-01
  • 2012-01-27
  • 1970-01-01
  • 2015-08-23
  • 2015-07-20
相关资源
最近更新 更多