TextView tv = (TextView) findViewById(R.id.textview);
tv.setText(string);
tv.setDrawingCacheEnabled(true);
tv.measure(View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED), View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
tv.layout(0, 0, tv.getMeasuredWidth(), tv.getMeasuredHeight());
Bitmap bitmap = Bitmap.createBitmap(tv.getDrawingCache());
//千万别忘最后一步
tv.destroyDrawingCache();
Textview转化成Bitmap对象
最新推荐文章于 2022-09-07 17:50:59 发布