I have a LinearLayout set height as match_parent as below:
You need to wait View to be initialized first use View Tree Observer it waits until the view is created check out this
get layout height and width at run time android