0
當我屏幕截圖的時候。我無法成功地拍攝所有屏幕,只顯示路徑。 我想知道我的代碼有什麼問題。我希望有一個人可以幫助我。謝謝谷歌地圖V1的截圖
這是我的結果:
// Screen shot
private static Bitmap takeScreenShot(Activity activity) {
// View to shot View
View view = activity.getWindow().getDecorView();
//View view = getPopupViews(getDecorViews())[0];
Log.i("ABC", view.getClass().getName());
view.setDrawingCacheEnabled(true);
view.buildDrawingCache();
Bitmap b1 = view.getDrawingCache();
// the height
Rect frame = new Rect();
view.getWindowVisibleDisplayFrame(frame);
int statusBarHeight = frame.top;
System.out.println(statusBarHeight);
// width and height
int width = activity.getWindowManager().getDefaultDisplay().getWidth();
int height = activity.getWindowManager().getDefaultDisplay().getHeight();
// del the state bar
// Bitmap b = Bitmap.createBitmap(b1, 0, 25, 320, 455);
Bitmap b = Bitmap.createBitmap(b1, 0, statusBarHeight, width, height - statusBarHeight);
view.destroyDrawingCache();
return b;
}
// save image to sdcard
private static void savePic(Bitmap b, String strFileName) {
FileOutputStream fos = null;
try {
fos = new FileOutputStream(strFileName);
if (null != fos) {
b.compress(Bitmap.CompressFormat.JPEG, 90, fos);
fos.flush();
fos.close();
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
private void shoot() {
shoot(this);
}
// call function
public static void shoot(Activity a) {
savePic(takeScreenShot(a), "data/data/com.example.map/"+number+".png");
}
結果圖像鏈接嘗試這個代碼,並通過MapView的不工作 – Ajay 2013-04-23 12:22:26
可以看到現在結果? – 2013-04-23 12:28:25
「全屏」是什麼意思?你還想在屏幕截圖中添加上方按鈕和標題欄 – Ajay 2013-04-23 12:36:58