search

Home  >  Q&A  >  body text

android - 如何得到fragment的高度?

如何得到fragment的高度?

迷茫迷茫2771 days ago681

reply all(4)I'll reply

  • 怪我咯

    怪我咯2017-04-17 17:30:23

    Fragment is attached to the View container. Isn’t the height of the View the same as the height of the Fragment?

    reply
    0
  • PHPz

    PHPz2017-04-17 17:30:23

    fragment没有提供像Activity类似的onWindowFocusChanged方法,但可以使用ViewTreeObserver Come and get it.

    reply
    0
  • 阿神

    阿神2017-04-17 17:30:23

    transaction.replace(frameLayout, fragment)
    Just get the height of frameLayout

    reply
    0
  • 阿神

    阿神2017-04-17 17:30:23

    fragment.getView().getMeasuredHeight()

    reply
    0
  • Cancelreply