产品要求的新需求,在一个分享的页面对当前的页面截屏保存图片然后在第三方应用中进行图片分享,这里就做了一个简单的demo,为了更好的用户体验就做了一个类似系统按钮截屏的效果,截屏之后将截图做了一个本地存储操作,好了交代的也差不多了先来看效果图


就直接上代码
/**
* 弹出截屏框
*/
private void popShotSrceenDialog() {
final AlertDialog cutDialog = new AlertDialog.Builder(this).create();
View dialogView = View.inflate(this, R.layout.show_cut_screen_layout, null);
ImageView showImg = (ImageView) dialogView.findViewById(R.id.show_cut_screen_img);
//获取当前屏幕的大小
int width = getWindow().getDecorView().getRootView().getWidth();
int height = getWindow().getDecorView().getRootView().getHeight();
//生成相同大小的图片
Bitmap temBitmap = Bitma

这篇博客介绍了一个在Android应用中实现类似系统截屏功能的简单demo,包括截图并保存图片到本地的过程。在Android 6.0及以上版本,需要动态申请存储权限以确保截图保存成功。

525

被折叠的 条评论
为什么被折叠?



