1

I have a relative layout in my app which im trying to take screenshot of. The problem is that it has CircularImageView in it (https://github.com/lopspower/CircularImageView) and the whole image is transformed and no longer cropped to center.

The code goes like this:

View rl = findViewById(R.id.toBeScreenShot);
rl.setDrawingCacheEnabled(true);
Bitmap screenshot = Bitmap.createBitmap(rl.getWidth(),rl.getHeight(), Bitmap.Config.ARGB_8888);
Canvas c = new Canvas(screenshot);
rl.draw(c);
rl.setDrawingCacheEnabled(false);

And this is the result:

enter image description here

The XML code is too big to share, there is a Relative layout that im taking screenshot of (in code, its 'rl'). Then there is a FrameLayout, then two LinearLayouts, some ImageViews and then there is the CircularImageView:

<com.mikhaellopez.circularimageview.CircularImageView
    android:id="@+id/userPicture"
    android:layout_width="@dimen/_120sdp"
    android:layout_height="@dimen/_130sdp"
    android:layout_gravity="center"
    app:civ_border="false" />

Any idea what might cause this thing to happen?

petrumo
  • 1,116
  • 9
  • 18
Vladimir Marton
  • 569
  • 4
  • 31

1 Answers1

0

So far I've been able to figure out that the bug must have something to do with the library that I'm using. So I tried to figure out some other way to create circular image, and I found this answer from Waza_Be:

https://stackoverflow.com/a/14180142/6148510

After some short testing, the screenshot of this circular bitmap works properly. If there will be no answer to my problem, I will mark this workaround as a correct answer.

Community
  • 1
  • 1
Vladimir Marton
  • 569
  • 4
  • 31
  • surely, as you can see in the link reported by yourself, you should use width/2 and heigth/2 – firegloves Jan 19 '17 at 14:50
  • if /2 is the solution please write an answer, I'll vote up it – firegloves Jan 19 '17 at 14:54
  • nope, CircularImageView does the division by itself, also if you notice that the 1/4-circle on the picture is not really a full quarter. Its close but putting 4 of them together would not make a flawless circle. – Vladimir Marton Jan 19 '17 at 14:57