Android GoogleMap v2自定义信息窗口大小

Android GoogleMap v2自定义信息窗口大小,android,google-maps,google-maps-markers,google-maps-android-api-2,Android,Google Maps,Google Maps Markers,Google Maps Android Api 2,我正在测试InfoWindowAdapter提供自定义内容视图。我尝试过简单地返回新视图(上下文),以及使用特定的大小来扩展布局。然而,显示的InfoWindow(看起来大小相同)呈现为一个巨大的显示,比默认的InfoWindow大得多。我在getInfoWindow(Marker)中返回null,在getInfoContents(Marker)中返回我所需的内容视图 googleMap.setInfoWindowAdapter(new GoogleMap.InfoWindowAdapter

我正在测试
InfoWindowAdapter
提供自定义内容
视图
。我尝试过简单地返回
新视图(上下文)
,以及使用特定的大小来扩展布局。然而,显示的InfoWindow(看起来大小相同)呈现为一个巨大的显示,比默认的InfoWindow大得多。我在
getInfoWindow(Marker)
中返回
null
,在
getInfoContents(Marker)
中返回我所需的内容
视图

  googleMap.setInfoWindowAdapter(new GoogleMap.InfoWindowAdapter() {

  @Override
  public View getInfoWindow(Marker marker) {

    return null;
  }

  @Override
  public View getInfoContents(Marker marker) {

    // Inflate custom layout
    View v = getLayoutInflater().inflate(R.layout.marker_view, null);

    // Set desired height and width
    v.setLayoutParams(new RelativeLayout.LayoutParams(500, RelativeLayout.LayoutParams.WRAP_CONTENT));

    TextView id = (TextView) v.findViewById(R.id.marker_id);
    TextView alt = (TextView) v.findViewById(R.id.marker_altitude);
    TextView name = (TextView) v.findViewById(R.id.marker_name);

    id.setText("Marker ID");
    name.setText("Marker Name");
    alt.setText("Marker Altitude");

    return v;
  }
});
}
祝你好运