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.