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

android View 转Bit地图

2012-08-08 
android View 转Bitmap/***added by yangguangfu Draw the view into a bitmap.*/privateBitmap getViewBi

android View 转Bitmap

 /**     *  added by yangguangfu Draw the view into a bitmap.     */   private  Bitmap getViewBitmap(View v) {      Bitmap bitmap=null;    if(v!=null){     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);            float alpha = v.getAlpha();            v.setAlpha(1.0f);            if (color != 0) {                v.destroyDrawingCache();            }            v.buildDrawingCache();            Bitmap cacheBitmap = v.getDrawingCache();            if (cacheBitmap == null) {                Log.e(TAG, "failed getViewBitmap(" + v + ")", new RuntimeException());                return null;            }             bitmap = Bitmap.createBitmap(cacheBitmap);            // Restore the view            v.destroyDrawingCache();            v.setAlpha(alpha);            v.setWillNotCacheDrawing(willNotCache);            v.setDrawingCacheBackgroundColor(color);    }               return bitmap;    }
1 楼 hoyee1223 2011-09-16   v.getAlpha();  
v.setAlpha(1.0f); 

这两个方法没有定义啊,View没有两个方法吧?
2 楼 423884605 2012-02-11   good

热点排行