bitmap - Android - getDrawingCache - black screen -
I have read many posts on this topic, but none of them is helping.
I am trying to capture the screen shot of the current screen. For this I am using getDrawingCache. Here is my code:
mRootView.get (). SetDrawingCacheEnabled (true); . MRootView.get () buildDrawingCache (); Bitmap screenshot = bitmap.creditbetaMap (mRootView.get (). GetDrawingCache ()); MRootView.get () setDrawingCacheEnabled (incorrect). The resulting bitmap is always black.
mRootView is a weak reference drawer layout, which is my root view.
Here's what I've tried:
- Adding a solution and layout call (though it should not be necessary because this code runs when a button is pressed, Then the scene should already be excluded).
- Before setting the layer type, set the LAYER_TYPE_NONE before you call the drawing cache enabled (true)
- Using a different view as the root view (for example, Dreverlayout Inside a ViewPager).
You can draw your view to the canvas -
Pass your main layout reference of this method -
Bitmap file = save (layout); Bitmap save (see V) {bitmap b = bitmap.ctreitmap (v.getWidth), v.getHeight (), bitmap config.rg_8888); Canvas C = new canvas (B); V.draw (c); Return b; }
Comments
Post a Comment