카테고리 없음

[android] PopupWindows 및 AlertDialogs를 포함한 활동 내용의 스크린 샷을 찍는 방법은 무엇입니까?

행복을전해요 2021. 2. 17. 09:23

Try making a bitmap of the activity window, and a bitmap of the dialog window, then using a canvas to layer the images over eachother.

Display display = getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getSize(size);
int width = size.x;
int height = size.y;

public static Bitmap overlay(Bitmap bmp1, Bitmap bmp2) {
    try {
             Bitmap bmOverlay = Bitmap.createBitmap(width, height,  bmp1.getConfig());
                      Canvas canvas = new Canvas(bmOverlay);
                               canvas.drawBitmap(bmp1, 0, 0, null);
                                        canvas.drawBitmap(bmp2, 0, 0, null);
                                                 return bmOverlay;
                                                 
                                                  } catch (Exception e) { e.printStackTrace() }
                                                  
-------------------

모든 것을 캡처하려면 ddms 도구를 사용하여 스크린 샷을 찍은 다음 알림 표시 줄과 같이 원하지 않는 것을 잘라 내야한다고 생각합니다.



출처
https://stackoverflow.com/questions/22079813