Android 實現截圖

2021-09-01 07:47:10 字數 912 閱讀 5755

android實現截圖功能,使用view的方法,得到以時間戳命名的png

view view = v.getrootview();

view.setdrawingcacheenabled(true);

view.builddrawingcache();

bitmap bitmap1 = view.getdrawingcache(); //取得全屏,包括狀態列,標題欄

//獲取狀態列高度

rect frame = new rect();

androidsamplesactivity.this.getwindow().getdecorview().getwindowvisibledisplayframe(frame);

int statusbarheight = frame.top;

int width = androidsamplesactivity.this.getwindowmanager().getdefaultdisplay().getwidth();

int height = androidsamplesactivity.this.getwindowmanager().getdefaultdisplay().getheight();

//去除狀態列

bitmap bitmap = bitmap.createbitmap(bitmap1, 0, statusbarheight, width, height - statusbarheight);

try catch (filenotfoundexception e) catch (ioexception e)

但fileoutputstream out = new fileoutputstream(fname);要正常執行的話,要在androidmanifest.xml檔案中加

,即開啟檔案寫許可權,外部儲存許可權。

Android截圖分享

android截圖並進行分享應該是乙個比較好用的功能,可惜在應用中見的不多 1.截圖 準備截圖 public void prepareshoot imgpath rootpath if imgpathfile.equals imgpath colorgoshareimga.png else else...

Android截圖方式

2017.5.6安卓巴士全球開發者論壇 廈門站 這個初夏 小巴仔想和程式設計師哥哥去廈門玩耍 你來嗎?android截圖 android截圖的原理 獲取具體需要截圖的區域的bitmap,然後繪製在畫布上,儲存為後進行分享或者其它用途 在截圖功能中,有時需要擷取全屏的內容,有時需要擷取超過一屏的內容 ...

android 截圖內容的獲取

那麼來講一下如何獲取。當然截圖的快捷鍵自己網路查詢。主要用到的類為contentobserver,下面來看看詳細的 private static final string external content uri matcher mediastore.images.media.external co...