I want to create container of btns which is similar to wrap panel. My way of thinking is to get firstly the width of screen. Secondly I would create the btn in code behind then check if there is enough space for it in row of table, if not I would add it to next row of table.
The problem is that the button's width is not constant( we cans say that width is equal wrap_content), so I need to know what is the width of btn before to check if is enough space for it.
When I try do this by getWidth()
I get always 0.
I can't do this by tree observer cause the btn is not added yet to layout.
One thing which comes to my mind is to add some simple btn, without any letters, then add one letter after another and check after every added sign how the width changed and find some dependency.
Have you any idea how to do it in other way ?