首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > Android >

android 把view转成bit地图

2012-09-25 
android 把view转成bitmapprivate Bitmap getViewBitmap(View v) {v.clearFocus()v.setPressed(false)bo

android 把view转成bitmap

private Bitmap getViewBitmap(View v) {        v.clearFocus();        v.setPressed(false);        boolean willNotCache = v.willNotCacheDrawing();        v.setWillNotCacheDrawing(false);        // Reset the drawing cache background color to fully transparent        // for the duration of this operation        int color = v.getDrawingCacheBackgroundColor();        v.setDrawingCacheBackgroundColor(0);        if (color != 0) {            v.destroyDrawingCache();        }        v.buildDrawingCache();        Bitmap cacheBitmap = v.getDrawingCache();        if (cacheBitmap == null) {            Log.e("TTTTTTTTActivity", "failed getViewBitmap(" + v + ")", new RuntimeException());            return null;        }        Bitmap bitmap = Bitmap.createBitmap(cacheBitmap);        // Restore the view        v.destroyDrawingCache();        v.setWillNotCacheDrawing(willNotCache);        v.setDrawingCacheBackgroundColor(color);        return bitmap;    }

?

1 楼 cnhua5 2012-03-01   我的view 是通过LayoutInflater mInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        vv = mInflater.inflate(R.layout.foreflect, null);得到的,为什么返回的bitmap高宽都是空???

热点排行