I have a view made up of TableLayout, TableRow and TextView
. I want it to look like a grid. I need to get the height and width of this grid. The methods
CORRECTION: I found out that the above solution is terrible. Especially when your phone is slow. And here, I found another solution: calculate out the px value of the element, including the margins and paddings: dp to px: https://stackoverflow.com/a/6327095/1982712
or dimens.xml to px: https://stackoverflow.com/a/16276351/1982712
sp to px: https://stackoverflow.com/a/9219417/1982712 (reverse the solution)
or dimens to px: https://stackoverflow.com/a/16276351/1982712
and that's it.