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

后端 未结 5 2073
渐次进展
渐次进展 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:02

    Just add a method to your custom view that you call when onSizeChanged takes place in the Activity. Pass the new values to the view as parameters of the called method. Then execute whatever operations need to take place when your custom view changes size.

提交回复
热议问题