獲取當面屏幕截圖

public Bitmap Setbitmap(Activity activity) {        //獲取最頂上的view        View view = activity.getWindow().getDecorView();        view.buildDrawingCache();        //獲取狀態欄的高度        Rect rect = new Rect();        view.getWindowVisibleDisplayFrame(rect);        int h = rect.top;        Display display = activity.getWindowManager().getDefaultDisplay();       int width = display.getWidth();        int height = display.getHeight();        view.setDrawingCacheEnabled(true);//獲得去除狀態欄的bitmap        Bitmap bitmap = Bitmap.createBitmap(view.getDrawingCache(),0, h, width, height - h);        view.destroyDrawingCache();        return  bitmap;    }
相關文章
相關標籤/搜索