How to re-size fragment and set to Google Map V2?

烈酒焚心 提交于 2019-12-11 14:09:47

问题


I am trying to create Facebook like slider from the following answer, where i want to change map width at a run time.

I tried inside bindComponent method , but its not working for me..

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" />

Activity

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




}
  }

Any Help would be highly appreciated.


回答1:


I would recomend you check this library. I think it's best i ever seen in web for implementing Facebook like Sliding Menu



来源:https://stackoverflow.com/questions/14500927/how-to-re-size-fragment-and-set-to-google-map-v2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!