我有一个String text = "Some text"
.
现在我需要知道文本的高度是多少,如果我将它放在 TextView 中,例如width = x dp
和height = y dp
。
例如在 iOS 中我可以这样做:
CGSize size = [self.text sizeWithFont:[UIFont fontWithName:fontName size:fontSize]
constrainedToSize:CGSizeMake(100, 10000)
lineBreakMode:0];
Paint.getTextBounds()
在这里不起作用,因为它不会将文本转换为行。