When can I find out the width/height of my view

Posted by michael on Stack Overflow See other posts from Stack Overflow or by michael
Published on 2012-06-06T22:36:59Z Indexed on 2012/06/06 22:40 UTC
Read the original article Hit count: 169

Filed under:

When is the earliest I can find out the actual (after layout) width/height of my view? I tried to do that

@Override
protected void onFinishInflate() {
    super.onFinishInflate();

    w = getWidth();
    h = getHeight();
}

But it gives me 0. I have cases in which the view is invisible in the beginning and that programmically become visible.

I think I can do that in onDraw(), but i dont' want to do that in everything I draw() something.

© Stack Overflow or respective owner

Related posts about android