可以用map v2创建一个透明的信息窗口吗?

时间:2013-09-27 08:06:06

标签: android google-maps

Hieveryone,一个问题。我应用这样的infowindows的背景:

android:background="#55000000"

但似乎总是背后有白色背景,是否有可能摆脱它? 谢谢!

enter image description here

1 个答案:

答案 0 :(得分:3)

实现您自己的InfoWindowAdapter以自定义设计infoWindow

示例代码

    private final View mWindow;

    public MarkerAdapter() {
        mWindow = getLayoutInflater().inflate(R.layout.custom_info_window,
                null);
    }

    @Override
    public View getInfoContents(Marker mark) {

        return null;
    }

    @Override
    public View getInfoWindow(Marker marker) {

        render(marker, mWindow);
        return mWindow;
    }

    private void render(Marker marker, View view) {
        int badge;
        // Use the equals() method on a Marker to check for equals. Do not
        // use ==.
        badge = R.drawable.ic_launcher;

        ((ImageView) view.findViewById(R.id.badge)).setImageResource(badge);

        String title = marker.getTitle();
        TextView titleUi = ((TextView) view.findViewById(R.id.title));

        titleUi.setText(title);

        String snippet = marker.getSnippet();
        TextView snippetUi = ((TextView) view.findViewById(R.id.snippet));

        snippetUi.setText(snippet);

    }

}

然后将其称为

mMap.setInfoWindowAdapter(new MarkerAdapter());