Android screenshot from code. Got it but not perfect

前端 未结 6 553
攒了一身酷
攒了一身酷 2021-02-04 21:47

I\'m trying to take a screenshot in code in Android. Actually the screenshot is the bitmap of the main RelativeLayout. The screenshot is taken but the content appears wrong, the

6条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-04 22:20

    Remove the lines:

    v.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED),
    MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
    //v.layout(0, 0, v.getMeasuredWidth(), v.getMeasuredHeight());
    v.layout(0, 0, v.getWidth(), v.getHeight());
    

提交回复
热议问题