0

I'm inflating a ViewGroup for export into a PDF document. After inflating it from xml file I am filling it with images and texts. Now when I try to draw this ViewGroup in the canvas of a PDF page, the height of the VieGroup is zero. And the canvas is empty.

This is the code:

View pdfRowLayout = ltInflater.inflate(R.layout.pdf_export_row_layout,
                    (ViewGroup) parent, false);

            TextView action = (TextView) pdfRowLayout.findViewById(R.id.pdf_action_field);
            action.setText(host.getDataProvider().getChildItem(curGroupPosition, 1).getText());

            ImageView avatar = (ImageView) pdfRowLayout.findViewById(R.id.pdf_avatar);
            avatar.setImageBitmap(host.getDataProvider().getGroupItem(curGroupPosition).getGroupImage());

I understand that I need to wait till the layout is fully inflated with a specific listener. But do I have to wait somehow for all the data to get in resizing the layout?

rommex
  • 763
  • 1
  • 8
  • 21
  • 1
    See [this](http://stackoverflow.com/questions/4680499/how-to-get-the-width-and-height-of-an-android-widget-imageview) post for getting the view's width/height on run-time. – Asaf Pinhassi Nov 05 '15 at 16:25

1 Answers1

-1

You could simply use the onResume() listener of the fragment/activity, this method makes the fragment/activity begin interacting with the user, which means that the fragment is fully visible for the user.

Ichor de Dionysos
  • 1,107
  • 1
  • 8
  • 30
  • 1
    It is not correct. In `onResume()` views aren't still laid out. – Onik Nov 05 '15 at 17:04
  • Could you provide some code in your question what you have already done and how you "fill your xml file with images and texts" because in the onStart and espacially in onResume your Fragments and Activities are all fully visible – Ichor de Dionysos Nov 05 '15 at 17:10
  • Take a look at [this answer](http://stackoverflow.com/questions/3591784/getwidth-and-getheight-of-view-returns-0/24035591#24035591) – Onik Nov 05 '15 at 17:14