I have created a custom view to pack 25 circles with different radii within the screen.
For this, it involves many calculations that requires the getWidth(), getHeight(), getLeft(), getRight() etc. And I have exposed a method to set the data.
As soon as I set the data, I try to perform the calculation and then invalidate. But always, the getWidth(), getHeight(), getLeft(), getRight() returns zero
As a workaround, I performed the calculation in onLayout() override. So when I set data for the view, I invoke requestlayout() and invalidate(). This is working fine for the time being. But I feel this is not the right way to get it done.
Is there any recommended way of doing this.