Reputation: 14896
Is there a direct programmatic way to get a fill_parent View's pixel height and width? For instance a view in a grid layout in a tab. Or do I have to get the window size and subtract the static sizes of the views around it?
Upvotes: 18
Views: 25024
Reputation: 822
There's the onMeasure()
method, not sure if that will do what you need. http://developer.android.com/guide/topics/ui/custom-components.html
Upvotes: 0
Reputation: 1090
You can get the views parent by calling myView.getParent()
and with getWidth()
and getHeight()
you get the pixel you need.
the documentation is providing more information to this topic
http://developer.android.com/reference/android/view/View.html
Upvotes: 19