Android实现对Dialog的截图并保存在本地
来源:互联网 发布:墨西哥域名注册 编辑:程序博客网 时间:2024/05/21 03:24
直接上代码:
public class TestDilaog extends Dialog { public TestDilaog(@NonNull Context context) { super(context, R.style.UpdateDialogTheme); } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.xxxx); //必须加这两句代码 this.getWindow().getDecorView().setDrawingCacheEnabled(true); this.getWindow().getDecorView().buildDrawingCache(); } //将图像保存到SD卡中 public void saveMyBitmap(){ if(!ImageTools.checkSDCardAvailable()){ T.show("SD卡不可用,保存失败"); return; } String currentPath= DemoApplication.GalleryPhoto+"/" +System.currentTimeMillis() + ".jpg"; File f = new File(currentPath); try { f.createNewFile(); } catch (IOException e) { // TODO Auto-generated catch block } FileOutputStream fOut = null; try { fOut = new FileOutputStream(f); } catch (Exception e) { e.printStackTrace(); } //获取bitmap关键代码 View dialogView = this.getWindow().getDecorView(); Bitmap dialogBitmap=dialogView.getDrawingCache(); dialogBitmap.compress(Bitmap.CompressFormat.JPEG, 100, fOut); try { fOut.flush(); } catch (IOException e) { e.printStackTrace(); } try { fOut.close(); } catch (IOException e) { e.printStackTrace(); } Toast.makeText(context,"图片保存到了"+currentPath,Toast.LENGTH_LONG).show(); MediaScannerConnection.scanFile(context, new String[]{currentPath}, null, null); }}
阅读全文
0 0
- Android实现对Dialog的截图并保存在本地
- Java实现截图并保存到本地
- java实现截图并保存到本地
- android中截图并保存本地
- android对View控件截图并保存
- java零碎总结---java实现截图并保存到本地
- Android拍照并保存在本地
- Unity3D截图并保存本地目录
- [Android] 拍照、截图、保存并显示在ImageView控件中
- android拍照,截图,保存并显示在ImageView控件中
- android实现屏幕截图并保存(去除状态栏)
- Android中简单实现从网络下在图片显示并保存在本地
- Cocos2dx基础之CCRenderTexture截图保存并使用的实现
- 基于Android实现保存图片到本地并可以在相册中显示出来
- Android实现保存图片到本地并在相册中显示
- 在Dialog中实现下拉框效果并对下拉框赋自定义的值
- python实现下载小说并保存在本地
- android调用系统相机拍照并保存在本地
- MTK6735 基本make、make clean命令
- android中自定义view的方法
- ajax 上传文件
- camera 模组(一)
- strhcr函数的使用简单示例
- Android实现对Dialog的截图并保存在本地
- DenseNet 简介
- ProtoBuf---基本使用
- 自然语言理解的简单梳理
- 【HDU1754】I Hate It(线段树)
- codility OddOccurrencesInArray
- 树形DP例题整理
- 中国历史的90%统治者不叫皇帝,叫“传统”
- eclipse 修改 ini文件的读取方式