Dan*_*son 2 android google-maps google-maps-markers google-maps-android-api-2
我正在测试InfoWindowAdapter提供的自定义内容View.我试过简单地返回new View(Context)以及给特定尺寸的布局充气.然而,显示的InfoWindow呈现(看起来大小相同)一个巨大的显示,比默认的InfoWindow大小大得多.我回国null在getInfoWindow(Marker)和我想要的内容View中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;
}
});
}
Run Code Online (Sandbox Code Playgroud)
祝好运.
| 归档时间: |
|
| 查看次数: |
3403 次 |
| 最近记录: |