如何得到fragment的高度?
业精于勤,荒于嬉;行成于思,毁于随。
Fragment is attached to the View container. Isn’t the height of the View the same as the height of the Fragment?
fragment没有提供像Activity类似的onWindowFocusChanged方法,但可以使用ViewTreeObserver Come and get it.
fragment
Activity
onWindowFocusChanged
ViewTreeObserver
transaction.replace(frameLayout, fragment)Just get the height of frameLayout
fragment.getView().getMeasuredHeight()
Fragment is attached to the View container. Isn’t the height of the View the same as the height of the Fragment?
fragment
没有提供像Activity
类似的onWindowFocusChanged
方法,但可以使用ViewTreeObserver
Come and get it.transaction.replace(frameLayout, fragment)
Just get the height of frameLayout
fragment.getView().getMeasuredHeight()