Actually, I was looking for the same functionality. It turns out to be much simpler, you do not even need a separate function.
If you just call getTextBounds () on the given string, the returned bounding box will already have this information.
For instance:
paint.getTextBounds(exampleString1 , 0, exampleString1.length(), bounds); if (bounds.bottom > 0) Log.i("Test", "String HAS descender"); else Log.i("Test", "String DOES NOT HAVE descender");
Just say that bounds.top tells you to ascend the line (it has a negative value, since the Y axis 0 indicates the baseline of the line), and bounds.bottom indicates the descent of the line (which may be 0 or a positive value for lines that have descent )
source share