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{
            
        }

 

转载于:https://www.cnblogs.com/lrfsmile/p/3830998.html

你可能感兴趣的:(Android 截取当前界面)