您的位置:首页 > 其它

将一个view对象转换为bitmap对象

2016-04-20 12:05 190 查看
 private Bitmap getViewBitmap(View addViewContent) {

        addViewContent.setDrawingCacheEnabled(true);

        addViewContent.measure(

                View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED),

                View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));

        addViewContent.layout(0, 0,

                addViewContent.getMeasuredWidth(),

                addViewContent.getMeasuredHeight());

        addViewContent.buildDrawingCache();

        Bitmap cacheBitmap = addViewContent.getDrawingCache();

        Bitmap bitmap = Bitmap.createBitmap(cacheBitmap);

        return bitmap;

    }
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息