Android 截取当前界面

View view=getLayoutInflater().inflate(R.layout.activity_main, null);
        view.setDrawingCacheEnabled(true);
        view.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED),MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
        view.layout(0, 0, view.getMeasuredWidth(), view.getMeasuredHeight());
        try{
            Bitmap bitmap=view.getDrawingCache();
            FileOutputStream fos=new FileOutputStream("/sdcard/test.png");
            bitmap.compress(CompressFormat.PNG, 100, fos);
            fos.close();
        }catch(Exception e){
            
        }finally{
            
        }

 

posted on 2014-07-08 10:37  StrongerRui  阅读(251)  评论(0编辑  收藏  举报

导航