Get parent Width and Height

Viewed 16854

I've create a custom view based on LinearLayout and I need to calculate the layout width and height according to the parent view but each time I use ((View)this.getParent()).getMeasuredWidth() I got 0 - I guess that I called this function too early!

Any ideas to how accomplish this functionality?

3 Answers

in Kotlin you can use like this :

   val height = (parent as View).height
Related