Android 把Layout变成图片

首先是XML读取

LinearLayout layout = (LinearLayout) LayoutInflater.from(
							mContext).inflate(R.layout.hotel_map_pop, null);

然后:

layout.setDrawingCacheEnabled(true);
					layout.measure(MeasureSpec.makeMeasureSpec(0,
							MeasureSpec.UNSPECIFIED), MeasureSpec
							.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
					layout.layout(0, 0, layout.getMeasuredWidth(),
							layout.getMeasuredHeight());
					layout.buildDrawingCache();
					Bitmap bitmap = layout.getDrawingCache();

然后,一个Layout就可以变成一个Bitmap啦

你可能感兴趣的:(Android)