LinearLayout height in onCreate is 0

前端 未结 1 682
深忆病人
深忆病人 2020-12-01 01:18

I\'m trying to dynamically adjust the height of my rows depending on the (screen height - my layout height) / list.size.

Unfortunately in the onCreate m

1条回答
  •  青春惊慌失措
    2020-12-01 01:38

    You have to wait until layout happens, which is after onCreate(). You can do so by listening to onSizeChanged() on a View or by posting a Runnable from onCreate() (myView.post(new Runnable() { ... })).

    0 讨论(0)
提交回复
热议问题