1

I have created a custom view (basically a chart). I instantiate the custom view in a layout file like this:

<com.package.customView android:visibility="visible" android:layout_width="match_parent" android:layout_height="wrap_content" other attributes .../>

I am able to see my view on a screen. Not a problem. I am able to dump this CustomView into a pdf via iTextView. Not a problem as well.

But if i set the visibility to gone, then i am unable to dump this CustomView into a pdf even when all steps remain the same as before. I want to be able to export a CustomView that's not visible on the screen. Is that possible? I tried setting visibility to invisible and it seems to work but then it takes up space (which appears blank on screen). So, ideally i would like it to be "gone" and still have my pdf report to be generated without a problem.

On a general note, i would really ideally want to instantiate the CustomView programatically like this (and not depend on a layout xml file per se)

CustomView myView = new CustomView(app_context_here, view_attrs_here);

and then set layout params on it and export it to pdf.

Is there a way to achieve what i want? Any pointers are greatly appreciated.

Thanks and Best Regards.

VJ Vélan Solutions
  • 6,434
  • 5
  • 49
  • 63

1 Answers1

2

use FrameLayout as parent of your customview and other views that you want to display on screen, and make customview invisible. so that it wont take up space..

Ri d
  • 21
  • 3
  • When you set a view's visibility (custom or standard widget) to invisible, it still takes space. So, i am afraid that's not an option. – VJ Vélan Solutions Oct 20 '15 at 19:10
  • That's right but if you use FrameLayout as parent of more then one views then you can hide one view behind the other..I hope you get it.. – Ri d Oct 21 '15 at 07:20