Gettextbounds in android

后端 未结 4 1583
生来不讨喜
生来不讨喜 2020-12-13 16:20

We used to find the rectangle which fits the given text, for example if give \"TESTING\" in gettextbounds api it will give a rectangle that fits the given string \"TESTING\"

4条回答
  •  醉梦人生
    2020-12-13 16:25

    Here's a way that works for me: use Paint.measureText(text) to get text's width and Paint.getTextBounds(text, 0, text.length(), bounds) to get text's height (height = bounds.height())

提交回复
热议问题