网上找了好几种都不能用,生成的bitmap为null,不知道怎么回事,
这一种可以,所以记录下来,以后万一哪天用到了呢?
private BitmapDescriptor getMarkerBigBitmap(int count){
View view = LayoutInflater.from(this).inflate(R.layout.markerbig, null);
TextView tv_count = (TextView)view.findViewById(R.id.tv_markercount);
tv_count.setText(count+"");
view.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED), MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
view.layout(0, 0, view.getMeasuredWidth(), view.getMeasuredHeight());
view.buildDrawingCache();
Bitmap bitmap = view.getDrawingCache();
if(bitmap == null){
Logger.e(TAG, "bitmap is null");
}
BitmapDescriptor bitmap1 = BitmapDescriptorFactory.fromBitmap(bitmap);
return bitmap1;
}