Android普通截屏(不包括状态栏内容无状态栏占位仅包含应用程序)

来源:互联网 发布:日本视频翻译软件 编辑:程序博客网 时间:2024/06/05 23:05
    public static Bitmap normalShot(Activity activity) {        View decorView = activity.getWindow().getDecorView();        decorView.setDrawingCacheEnabled(true);        decorView.buildDrawingCache();                Rect outRect = new Rect();        decorView.getWindowVisibleDisplayFrame(outRect);        int statusBarHeight = outRect.top;//状态栏高度        Bitmap bitmap = Bitmap.createBitmap(decorView.getDrawingCache(),                0, statusBarHeight,                decorView.getMeasuredWidth(), decorView.getMeasuredHeight() - statusBarHeight);        decorView.setDrawingCacheEnabled(false);        decorView.destroyDrawingCache();        return bitmap;    }


效果:







微信个人公众号,纯属娱乐哦~~~


原创粉丝点击