I know that doing view size calculations for placement is frowned up.
Android layout managers should place all views properly.
However there are some legitimate cases when some sort of calculations
should be done in order to provide hints (ex. number of columns in a GridView
or sizing a text view to allow a minimum number of characters displayed in a line).
For these cases I would like to get the relevant view width/height info or
font width/height/etc.
However the getWidth()/getHeigth()/etc calls never return a valid value
unless the view has been rendered on display but then it is late.
It is a catch-22 situation.
I wonder if there is some way that I haven't found (the android api is big
to comprehend all in my mind) that makes what I have described above possible.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…