I rotate a view by an angle. I want to get bitmap from this view. I am getting bitmap by calling getdrawingcache()
, but not getting rotating view by an angle. It is giving a view without rotating.
Asked
Active
Viewed 134 times
1

TheSoal
- 11
- 2
-
I am using following code: private void captureUsingDrawingCache(){ targetView.buildDrawingCache(); Bitmap b1 = targetView.getDrawingCache(); Bitmap b = b1.copy(Bitmap.Config.ARGB_8888, false); BitmapDrawable d = new BitmapDrawable(b); canvasView.setImageDrawable(d); targetView.destroyDrawingCache(); } – TheSoal Nov 05 '15 at 14:21
-
1Do not add code in comment. Instead edit the question with this code. – Henry Nov 05 '15 at 14:23
-
check out my answer here: http://stackoverflow.com/questions/37254577/how-can-i-take-screenshot-of-rotated-textview-with-emoji/43116641#43116641 – Wops Mar 30 '17 at 11:32
1 Answers
0
For rotation view use this:
view.setRotation(45);
But your API must be higher than 11

walkmn
- 2,322
- 22
- 29
-
I already rotate a view. I am trying to get bitmap after rotate a view. – TheSoal Nov 05 '15 at 14:27
-
-
Try to call `getDrawingCache()` from parent view which include our rotated view – walkmn Nov 05 '15 at 14:47
-
1If i call getDrawingCache() from parent view, than it will create bitmap for all views containing in parent view. Is it possible to create bitmap of only targeted view which is rotated by an angle? – TheSoal Nov 06 '15 at 04:56
-
ya, I think it is right solution: wrap your rotated-view to layout, and then call getDrawingCache() from this layout. – walkmn Nov 06 '15 at 11:31
-