getWidth and getHeight are returning a zero

The width and height are not defined until the view is actually rendered to the screen.

Use protected abstract void onLayout (boolean changed, int l, int t, int r, int b) (which you override in your activity) to know when the sizes are ready.

Leave a Comment