diff --git a/chartLib/src/main/kotlin/info/appdev/charting/renderer/PieChartRenderer.kt b/chartLib/src/main/kotlin/info/appdev/charting/renderer/PieChartRenderer.kt index ba05989e2..f94c2301d 100644 --- a/chartLib/src/main/kotlin/info/appdev/charting/renderer/PieChartRenderer.kt +++ b/chartLib/src/main/kotlin/info/appdev/charting/renderer/PieChartRenderer.kt @@ -688,17 +688,27 @@ open class PieChartRenderer( val width = centerTextLastBounds.width() // If width is 0, it will crash. Always have a minimum of 1 - centerTextLayout = StaticLayout( +// centerTextLayout = StaticLayout( +// centerText, +// 0, +// centerText.length, +// paintCenterText, +// max(ceil(width.toDouble()), 1.0).toInt(), +// Layout.Alignment.ALIGN_CENTER, +// 1f, +// 0f, +// false +// ) + centerTextLayout = StaticLayout.Builder.obtain( centerText, 0, centerText.length, paintCenterText, - max(ceil(width.toDouble()), 1.0).toInt(), - Layout.Alignment.ALIGN_CENTER, - 1f, - 0f, - false - ) + max(ceil(width.toDouble()), 1.0).toInt() + ).setAlignment(Layout.Alignment.ALIGN_CENTER) + .setLineSpacing(0f, 1f) + .setIncludePad(false) + .build() } val layoutHeight = centerTextLayout!!.height.toFloat() @@ -710,9 +720,7 @@ open class PieChartRenderer( translate(boundingRect.left, boundingRect.top + (boundingRect.height() - layoutHeight) / 2f) centerTextLayout!!.draw(this) - } - PointF.recycleInstance(center) PointF.recycleInstance(offset) }