question

andrewd avatar image
andrewd asked Jeffrey Blattman commented

java.lang.IllegalArgumentException: Measured view width or height is 0 (While trying to print a view)

Hi,

When trying to print a view I get the following error:

java.lang.IllegalArgumentException: Measured view width or height is 0

I have set the layout:height, layout:width, minHeight and minWidth in the layout xml as well as setting minWidth and minHeight programmatically. but I still get the same error.

1 comment
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Jeffrey Blattman avatar image Jeffrey Blattman ♦♦ commented ·

As a work around, you can turn your View into a Bitmap and use ImagePrintJob.

0 Likes 0 ·

1 Answer

anthonypinto avatar image
anthonypinto answered Jeffrey Blattman commented

You will probably have to dig in further to get more detail and fully debug the situation, but be aware that before a view drawn to the screen it doesn't have dimensions yet.

3 comments
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

justinsouter avatar image justinsouter commented ·
@Jeffrey Blattman
I know this is a 3-year-old thread, and I didn't see a way to comment on it other than in the answer section, but your comment above implies that ViewPrintJob doesn't work. I'm having the same result as the original poster, whether I use a programmatically created web view, a view from my activity layout, or even the TextView example you posted in another thread. Please advise.
0 Likes 0 ·
zgreathouse avatar image zgreathouse justinsouter commented ·

Please post question in a new post a link to this one for reference.

0 Likes 0 ·

Welcome to the
Clover Developer Community