如何重新调整片段大小并设置为Google Map V2?

时间:2013-01-24 12:02:35

标签: android android-maps-v2

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

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

map.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);




}
  }

任何帮助都将受到高度赞赏。

1 个答案:

答案 0 :(得分:0)

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