-1
所以我的問題是這個代碼的輸出是(這個廣場之一),而不是我所期望的。任何想法爲什麼發生這種情況輸出意想不到,而試圖採取前景 - 屏幕截圖
我將進一步解釋這一點,輸出基本上是一個像圖像的方形,但不是真正的方形,但它包含所有的視圖,但它與我們所期望的不同,是壓縮的,全屏尺寸的圖像與所有視圖適當的位置:
代碼:
private Bitmap getScreenshot(int id) {
Log.d(TAG, "Creating screenshot");
RelativeLayout RL= (RelativeLayout)findViewById(id);
View v1 = getWindow().getDecorView().getRootView(); //or RL.getRootView();
v1.setDrawingCacheEnabled(true);
v1.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED),
MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
v1.layout(0, 0, v1.getMeasuredWidth(), v1.getMeasuredHeight());
v1.buildDrawingCache(true);
Bitmap bm = Bitmap.createBitmap(v1.getDrawingCache());
v1.setDrawingCacheEnabled(false);
return bm;
}
圖片:
我不能添加新的鏈接(我需要10和聲譽)。我只是絕望的管理員。鏈接:https://www.pixeldroidof.net/qcode.txt –
http://stackoverflow.com/questions/2661536/how-to-programmatically-take-a-screenshot-in-android/5651242#5651242請檢查此兩個鏈接 http://stackoverflow.com/questions/32624133/how-to-take-a-screen-shot-on-a-button-click-can-anyone-provide-a-android-code/32624305#32624305 –
如果你需要沒有標題欄的屏幕截圖,請查看http://stackoverflow.com/a/30212385/7320259 –