I'm creating a custom canvas as shown below with Text that is on the left side and also need text on the right as shown in the image below. I've got part of the text on the left side but how do I get the text to show on the left and right in a canvas?
Here's what I'd like to show :
Current Code:
private val textSize: Float = 70.toFloat()
private val groupSpacing = 100
private val paint = Paint()
init {
paint.textSize = textSize
}
override fun onDrawOver(c: Canvas, parent: RecyclerView, state: RecyclerView.State) {
for (i in 0 until parent.childCount) {
val view = parent.getChildAt(i)
val position = parent.getChildAdapterPosition(view)
if (position == 0) {
c.drawText(" Default", view.left.toFloat(),
view.top - groupSpacing / 2 + textSize / 3, paint)
} else if (position == 1) {
c.drawText(" Other", view.left.toFloat(),
view.top - groupSpacing / 2 + textSize / 3, paint)
}
}
}
The code above only shows Default