It is possible to calculate the text height with the MeasureMultilineTextHeight method from the StringUtils library.
Then you need to know the Padding of the view, which are are extra spaces arround the text.
Additionnally, buttons with the default background are smaller than the external dimensions.
Attached a small test project showing the differences.
The upper button is a 'standard' button with a height of 40dip and a text size of 22, your case.
The second button has a Padding of 0, 0, 0, 0.
The third button has a 'standard' color background, with the full dimensions.