I'm trying to save a view on a Canvas like this:
View view = getView();
Rect rect = new Rect();
rect.set(0, 0, width, height);
Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
int widthSpec = View.MeasureSpec.makeMeasureSpec(rect.width(), View.MeasureSpec.EXACTLY);
int heightSpec = View.MeasureSpec.makeMeasureSpec(rect.height(), View.MeasureSpec.EXACTLY);
view.measure(widthSpec, heightSpec);
view.layout(0, 0, rect.width(), rect.height());
view.draw(canvas);
imageView.setImageBitmap(bitmap);
The view is relatively complex and when showing the view on screen half of the layouts are missing. If I do not use a Canvas and ImageView, the view displays fine.
I have seen this question: Canvas not displaying all drawn parts in Custom View?, however I do not have Hardware Acceleration turned on (view.isHardwareAccelerated() returns false).
What can be the problem here? I've tried omitting some layouts from the view to make it less complex, but still the view doesn't display fully. It seems like it always stops displaying at the same point.
This is how to image looks like without using Canvas/Bitmap:
This is how it is displayed in the ImageView using Canvas/Bitmap: