Android 如何在单击地图覆盖时显示弹出窗口?
我想显示一个自定义图像,其中包含一些数据,同时单击我在android中添加到谷歌地图的地图覆盖 有谁能指导我如何创建自定义图像或东西,并在谷歌地图上显示一些数据Android 如何在单击地图覆盖时显示弹出窗口?,android,google-maps,Android,Google Maps,我想显示一个自定义图像,其中包含一些数据,同时单击我在android中添加到谷歌地图的地图覆盖 有谁能指导我如何创建自定义图像或东西,并在谷歌地图上显示一些数据 有人告诉我要使用自定义视图,但我对此一无所知。要创建显示图像和文本的自定义toast消息,请使用以下java代码 LayoutInflater inflater = getLayoutInflater(); View layout = inflater.inflate(R.layout.toast_layout, (ViewGroup)
有人告诉我要使用自定义视图,但我对此一无所知。要创建显示图像和文本的自定义toast消息,请使用以下java代码
LayoutInflater inflater = getLayoutInflater();
View layout = inflater.inflate(R.layout.toast_layout, (ViewGroup) findViewById(R.id.toast_layout_root));
TextView text = (TextView) layout.findViewById(R.id.text);
text.setText(content);
ImageView image = (ImageView) layout.findViewById(R.id.image);
image.setImageBitmap(bmImg);
Toast toast = new Toast(getApplicationContext());
toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
toast.setDuration(Toast.LENGTH_LONG);
toast.setView(layout);
toast.show();
还有这个布局文件
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/toast_layout_root"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="10dp"
android:background="#DAAA"
>
<ImageView android:id="@+id/image"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginRight="10dp"
/>
<TextView android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:textColor="#FFF"
/>
</LinearLayout>
演示如何在地图上方添加弹出面板(持久化的面板,不同于Toast
)。您可以将onclicklistener注册到地图覆盖上的某个点,然后显示在toast消息中。您还可以向toast消息中添加图像。如果你能详细说明一下你的问题,我可以举一些例子。是的,这很有帮助,但我可以在屏幕上展示一些东西,而不是烤面包片。土司出现然后消失。图像以toast的形式出现,但不是以图像的形式出现。添加另一个视图(可以是文本视图或图像视图)。当您点击该按钮时,您可以为此设置可见性()。更多信息:在“设置图像位图”之前,修复了初始化图像的代码。请确认。