如何创建动态编号引脚指针上的MapView?指针、引脚、编号、动态

2023-09-06 03:07:04 作者:斟满颓废.

我要显示某些位置上我的图形页面。这些位置将显示引脚,将有数字1,2,3 ......等(类似于谷歌地图的结果却是A,B,C ...)。我认为有所有数的管脚它是不可行的。

I want to display some locations on my MapView. These locations will show pins which will have numbers 1,2,3.. so on(Similar to Google maps result but it is A,B,C..). I think it is not feasible to have pins of all numbers.

有没有办法,我可以创建销背景的布局与的TextView 什么办法,我会动态地把数的TextView 和布局不适用作绘制针?

Is there any way that i can just create a layout with pin background with TextView and I will dynamically put number in TextView and that layout ill use as drawable pin??

还是要实现这一目标的任何其他方法?请提供一些建议。

Or any other method to achieve this?? Please provide some suggestions.

(我能表现出不同的绘制引脚图形页面。我只是想动态创建可绘)

(I am able to show different drawable pins on MapView.I just want to create drawables dynamically)

推荐答案

解决了这个。

充入针背景TextView的和动态设置位置为TextView的。

Inflated the TextView with pin background and dynamically set the position into TextView.

public Drawable createFromView(int positionNumber)
{
    LayoutInflater inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
    View view = inflater.inflate(R.drawable.pin_icon, null, false);
    TextView tv = (TextView) view.findViewById(R.id.pin_background);
    tv.setText("     "+ (positionNumber+1) );   // +1 since position is starting from 0
    tv.setDrawingCacheEnabled(true);
    tv.layout(0, 0, 50, 50);
    tv.buildDrawingCache();
    Bitmap b = Bitmap.createBitmap(tv.getDrawingCache());
    tv.setDrawingCacheEnabled(false);
    Drawable d = new BitmapDrawable(b);
    return d;
}
 
精彩推荐
图片推荐