I need to get the width of my main LinearLayout at creation time. Until it is actually draw the width is 0 – it isn’t drawn until after onCreate(...) is finished… So what I would like to do is be told when it has been drawn or resized and then grab the width from there. There doesn’t appear to be any Listeners for those so does anyone have any suggestions on how to get the width at creation?
I need to get the width of my main LinearLayout at creation time. Until
Share
maybe its crap answer..but do you need it really in onCreate method?
You can move everything from onCreate method in onStart method. There will be i think everything ok and you dont get width 0..
but if you really need it in onCreate method. You can override onSizeChanged method of your view. i am not right now on Pc with eclipse, but it will look something like:
EDIT:
sry..it was right answer but not so much :] there is basicaly no onSizeChangedListener, you need to write it yourself..
take a look on https://stackoverflow.com/a/5087960/1148979 there you can found the answer