热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

View生成bitmap方法

网上找了好几种都不能用,生成的bitmap为null,不知道怎么回事,这一种可以,所以记录下来,以后万一哪天用到了呢?privateBitmapDescriptorget

网上找了好几种都不能用,生成的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;

}

推荐阅读
author-avatar
茨冈人686
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有