Reputation: 36654
I have a custom DialogFragment
which I want to change its max_height dynamically according to its view's content size (wrap content).
I don't want the update of the max_height
to cause a jump in the UI so I planned to do it very early in the view's life cycle: onMeasure()
.
But how can I then notify the containing dialog
or dialogFragment
?
From Dialog fragment I can get its hosted view, but I cannot register it's onMeasure()
event.
From the view I can write code in the onMeasure()
method, but how will I get a reference to its containing dialog?
I saw this post, but chnging the hight at the onResume()
will cause a slagish UI (jump after the UI is seen)
https://stackoverflow.com/a/24213921/311130
Upvotes: 4
Views: 255
Reputation: 3331
How about ((View) view.getParent()).invalidate()
in the onMeasure()
of whichever view. I realize it's sort of wrong but should fix your issue with a one liner.
Admittedly this becomes a lot more cumbersome if the recalculated-height-View
is deeper in the View Heirarchy.
Upvotes: 0