问题
I am implementing a running tracker. My UI consists of a MapBox mapView and a display that contains a few layouts that make up the time, distance etc. The mapView takes up the top half of the parent layout while the display takes up the bottom half. After the run I want to take a screenshot of the screen and save the img as a Bitmap. However when I use the conventional way of getDrawingCache()
, the part of the img that is the mapView becomes a black box. Anyone knows how to solve this problem?
I have also tried the Canvas way but it did not work.
Below is the code to get the BitMap
view.setDrawingCacheEnabled(true);
view.buildDrawingCache(true);
Bitmap bitmap = Bitmap.createBitmap(view.getDrawingCache());
view.setDrawingCacheEnabled(false);
来源:https://stackoverflow.com/questions/62431836/mapbox-capture-whole-screen-but-mapboxmap-turned-out-to-be-black