Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LinearLayout height in onCreate is 0

Tags:

I'm trying to dynamically adjust the height of my rows depending on the (screen height - my layout height) / list.size.

Unfortunately in the onCreate method the layout height returns null (not so when i call it in an on click listener).

Is there another method I can call it in?

like image 931
Chr0n Avatar asked Aug 30 '10 15:08

Chr0n


People also ask

How do you find the height of a view?

You can use the window. innerHeight property to get the viewport height, and the window. innerWidth to get its width. let viewportHeight = window.

How do you find the height and width of a view?

The width and height can be obtained by calling getWidth() and getHeight().


1 Answers

You have to wait until layout happens, which is after onCreate(). You can do so by listening to onSizeChanged() on a View or by posting a Runnable from onCreate() (myView.post(new Runnable() { ... })).

like image 163
Romain Guy Avatar answered Sep 26 '22 01:09

Romain Guy