0

The custom view that extends a View is hosted in a fragment. It is added to the fragment in OncreateView() and is displays like it's supposed to. But when the user hit's home and comes back the that view and touches it, the app crashes and throws division by zero exception because the height is zero. At that point the system tries to draw the view without measuring the view, the onMeasure is skipped. Based on this SO answer the measure is accomplished after the view is attached. I called measure method in onAttachedToWindow but it still crashes. My question is how is the lifecycle affecting the drawing of the view in relation to the fragment?

The_Martian
  • 3,684
  • 5
  • 33
  • 61

1 Answers1

0

Was caused by a style in one of the textviews. Changed the style and the error went away. If you run into this exception make sure your xml file the exception raised from has all the views placed properly. If android doesn't measure your layout, chances are the layout contains wrong style or views.Inspect your layout allover very carefully.

The_Martian
  • 3,684
  • 5
  • 33
  • 61