gpt4 book ai didi

android - 自定义 InfoWindowAdapter 没有背景

转载 作者:行者123 更新时间:2023-11-29 21:21:05 26 4
gpt4 key购买 nike

我有一个奇怪的问题我设计了一个应用程序,用户可以在 Google map 版本 2 上看到某个点

我像这样使用 InfoWindowAdapter :

public class PopupAdapter implements  InfoWindowAdapter {
LayoutInflater inflater=null;
View view;
public PopupAdapter(LayoutInflater inflater) {
this.inflater=inflater;
view = this.inflater.inflate(R.layout.custom_info_window,null);
}

@Override
public View getInfoContents(Marker marker) {
// TODO Auto-generated method stub
return null;
}

@Override
public View getInfoWindow(Marker marker) {
final String title = marker.getTitle();
final TextView titleUi = ((TextView) view.findViewById(R.id.title));
if (title != null) {
titleUi.setText(title);
}
else {
titleUi.setText("");
}
final String snippet = marker.getSnippet();
final TextView snippetUi = ((TextView) view.findViewById(R.id.snippet));
if (snippet != null) {
snippetUi.setText(snippet);
}else {
snippetUi.setText("");
}
return view;
}

这是我的布局:

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:adjustViewBounds="true"
android:src="@drawable/ic_launcher"/>
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="12dp"
android:textStyle="bold"/>
<TextView
android:id="@+id/snippet"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="10dp"/>
</LinearLayout>

</LinearLayout>

但是当我在我的标记上弹出时,它没有任何背景,它在 map 上只显示一个没有弹出框架的简单文本

我试图解决这个问题,但似乎有些不寻常谁能帮帮我吗 ???非常感谢你

最佳答案

but when i get popup on my marker it is not have any background and it shows on map just a simple text with no popup frame

这就是您通过覆盖 getInfoWindow() 要求它执行的操作。如果您想要标准信息窗口框架,请改写 getInfoContents()。或者,将您自己的框架包含在您从 getInfoWindow() 返回的 View 中。

关于android - 自定义 InfoWindowAdapter 没有背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20723510/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com