当我搜索它时,我发现这些链接是解决方案:
http://android-codes-examples.blogspot.in/2011/04/google-map-example-in-android-with-info.html
和
https://github.com/jgilfelt/android-mapviewballoons
但我发现两者都很复杂。
我想知道是否有任何简单的方法可以做到这一点。就像膨胀布局并将其显示为点击标记上的弹出窗口一样。
现在我只使用Toast来显示用户点击标记时的信息。但主要的问题是我希望这个吐司(或其他布局)出现在点击标记的正上方,而不是默认的吐司位置。
谢谢
答案 0 :(得分:0)
试试这个,根据你的要求修改:
@SuppressWarnings({ "deprecation" })
@Override
protected boolean onTap(int index)
{
CustomView customView=new CustomView(MyMap.this);
absMap.removeAllViews();
absMap.addView(customView);
customView.setBackgroundResource(R.drawable.maplocation1);
customView.setVisibility(View.INVISIBLE);
customView.removeAllViews();
absMap.invalidate();
customView.bringToFront();
customView.setVisibility(View.VISIBLE);
TextView tv2=new TextView(MyMap.this);
// tv2.setText(overlayItemList.get(index).getTitle());
tv2.setWidth(170);
tv2.setSingleLine(true);
tv2.setEllipsize(TruncateAt.END);
tv2.setSingleLine(true);
tv2.setSingleLine();
tv2.setTextColor(Color.WHITE);
tv2.setTextSize(14);
tv2.setTypeface(Typeface.DEFAULT_BOLD);
TextView tv1=new TextView(MyMap.this);
tv1.setSingleLine();
tv1.setWidth(170);
tv1.setSingleLine(true);
tv1.setEllipsize(TruncateAt.END);
tv1.setSingleLine(true);
tv2.setText(overlayItemList.get(index).getSnippet());
tv1.setTextColor(Color.WHITE);
tv1.setTextSize(12);
tv1.setTypeface(Typeface.DEFAULT_BOLD);
customView.setTag(overlayItemList.get(index).getTitle());
customView.addView(tv2, new AbsoluteLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT,10,5));
customView.addView(tv1, new AbsoluteLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT,10,25));
customView.setLayoutParams(new MapView.LayoutParams( 250, 100, overlayItemList.get(index).getPoint(),-125,-137, MapView.LayoutParams.MODE_MAP|MapView.LayoutParams.TOP_LEFT));
customView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v)
{
}
});
}