Android: Need to use onSizeChanged for View.getWidth/Height() in class extending Activity

后端 未结 5 2074
渐次进展
渐次进展 2020-12-15 20:15

I want to use getWidth()/getHeight() to get width/height of my XML-Layout. I read I have to do it in the method onSizeChanged() otherwise I will get 0 ( Android: Get the scr

5条回答
  •  情歌与酒
    2020-12-15 21:19

    I had a similar problem (ie. calculating View sizes in an Activity after it was finished drawing).

    I overrode the Activity method : public void onWindowFocusChanged(boolean hasFocus) and it worked fine.

提交回复
热议问题