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

FC异常 :java.lang.IllegalArgumentException: x + width must be <= bit地图.width()

2013-10-27 
FC错误 :java.lang.IllegalArgumentException: x + width must be bitmap.width()调用截图方法时应用强

FC错误 :java.lang.IllegalArgumentException: x + width must be <= bitmap.width()
调用截图方法时应用强制退出:


public Bitmap takeScreenShot(Activity activity){  
        //View是你需要截图的View   
        View view = activity.getWindow().getDecorView();   
        view.setDrawingCacheEnabled(true);   
        view.buildDrawingCache();   
        b1 = view.getDrawingCache();   
           
        //获取状态栏高度   
        Rect frame = new Rect();     
        activity.getWindow().getDecorView().getWindowVisibleDisplayFrame(frame);     
        int statusBarHeight = frame.top;  
        //获取屏幕长和高   
        int width = activity.getWindowManager().getDefaultDisplay().getWidth();     
        //去掉标题栏   
        b = Bitmap.createBitmap(b1, 0, statusBarHeight, width, b1.getHeight()-statusBarHeight); 
        view.destroyDrawingCache();   
        return b;   
    } 

有知道怎么避免这个问题的吗?
[解决办法]
x + width must be <= bitmap.width()宽度超出了你要截的图的宽度~width改成b1.getWidth()试下~

热点排行