开发者

How to get tab's content's height and width in android?

开发者 https://www.devze.com 2023-03-01 13:44 出处:网络
I want to get the tab content i.e. framelayout\'s height and width in the first tab\'s activity. But it always returns 0. I know that we cannot call getHeight() or getMeasuredHeight() in onCreate() be

I want to get the tab content i.e. framelayout's height and width in the first tab's activity. But it always returns 0. I know that we cannot call getHeight() or getMeasuredHeight() in onCreate() because the view isnt drawn yet, but then when to call it ? In activity I dont have acce开发者_如何学Goss to onDraw or onMeasure method, so how and when can I access the height and width ?


http://developer.android.com/reference/android/view/ViewTreeObserver.OnGlobalLayoutListener.html You can refer to this ....

Note : The onGlobalLayout() will be called if there is

  1. Any changes in the view like change in Screen Orientation
  2. Any changes in layout while scrolling or while hiding some widgets, this method will be called
0

精彩评论

暂无评论...
验证码 换一张
取 消