Android-在地图上点击标记的位置显示自定义对话框

时间:2016-01-20 10:50:00

标签: android android-layout dialog google-maps-markers infowindow

如何在地图上单击标记的坐标处显示自定义对话框。目前我能够显示我选择的对话框,但它的位置并不准确。    以下是代码示例:

  LayoutInflater layoutInflater = LayoutInflater.from(this);
    View promptView = layoutInflater.inflate(R.layout.custom_info_window, null);

    Dialog alertD = new Dialog(context);
    alertD.requestWindowFeature(Window.FEATURE_NO_TITLE);
    alertD.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
    alertD.getWindow().setLayout(40, 40);

    Point markerScreenPosition = mMap.getProjection().toScreenLocation(marker.getPosition());

    WindowManager.LayoutParams wmlp = alertD.getWindow().getAttributes();

    wmlp.x = markerScreenPosition.x;
    wmlp.y = markerScreenPosition.y;

0 个答案:

没有答案