国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開APP
userphoto
未登錄

開通VIP,暢享免費電子書等14項超值服

開通VIP
Android 截屏并寫入SD卡中

-----------截屏方法

  1. private Bitmap shot() {    
  2.     View views = getWindow().getDecorView();  
  3.     views.buildDrawingCache();  
  4.   
  5.     // 獲取狀態(tài)欄高度  
  6.     Rect frames = new Rect();  
  7.     views.getWindowVisibleDisplayFrame(frames);  
  8.     int statusBarHeights = frames.top;  
  9.     Display display = getWindowManager().getDefaultDisplay();  
  10.     int widths = display.getWidth();  
  11.     int heights = display.getHeight();  
  12.     //第一種方式       
  13.     views.layout(0, statusBarHeights,widths, heights - statusBarHeights);  
  14.     views.setDrawingCacheEnabled(true);//允許當前窗口保存緩存信息 ,兩種方式都需要加上  
  15.     Bitmap bmp = Bitmap.createBitmap(views.getDrawingCache());  
  16.     //第二種方式       
  17.     // 1、source 位圖  2、X x坐標的第一個像素  3、Y y坐標的第一個像素  4、寬度的像素在每一行  5、高度的行數(shù)  
  18.     //Bitmap bmp = Bitmap.createBitmap(views.getDrawingCache(), 0, statusBarHeights,widths, heights - statusBarHeights);  
  19.     return bmp;    
  20. }  


------------保存到SD卡方法

  1. try {  
  2.     String status = Environment.getExternalStorageState();  
  3.     // 判斷SD卡是否存在  
  4.     if (status.equals(Environment.MEDIA_MOUNTED)) {  
  5.         File destDir = new File("文件夾名");  
  6.           
  7.         if (!destDir.exists()) {  
  8.             // 創(chuàng)建文件夾  
  9.             destDir.mkdirs();  
  10.         }  
  11.         File file = new File("圖片名");  
  12.         // 判斷文件夾是否存在  
  13.         if (file.exists()) {  
  14.             String pic_path ="文件夾名" +"圖片名"+".png";  
  15.             FileOutputStream out = new FileOutputStream(pic_path);  
  16.             shot().compress(Bitmap.CompressFormat.PNG,100, out);  
  17.             out.flush();  
  18.             out.close();  
  19.         }  
  20.     }  
  21. } catch (FileNotFoundException e) {  
  22.     e.printStackTrace();  
  23. } catch (IOException e) {  
  24.     e.printStackTrace();  
  25. }  


 

--------把Bitmap轉(zhuǎn)為Drawable 放進imageView中

  1. //Bitmap-->Drawable    
  2.               BitmapDrawable bd=new BitmapDrawable(shot());    
  3.               imageView.setBackgroundDrawable(bd);    
  4.               imageView.setImageBitmap(shot());   


 

 

 

 

本站僅提供存儲服務,所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊舉報。
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
Android 啟動時加載SD卡的方法
Android手機SD卡【清理SD卡時常見的文件目錄】
Android系統(tǒng)下SD卡各文件夾功能解析
【新提醒】Android手機提示SD卡損壞,并且不能讀取sd卡的解決
【Android系統(tǒng)下SD卡各文件夾功能解析】
魅族M9 將應用程序安裝到SD卡的方法
更多類似文章 >>
生活服務
分享 收藏 導長圖 關注 下載文章
綁定賬號成功
后續(xù)可登錄賬號暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點擊這里聯(lián)系客服!

聯(lián)系客服