Open mnallamalli97 opened 3 years ago
You can calculate max width of your RowHeaders:
private fun getMaxWidth(rowHeaderList: List<RowHeaderData>): Int {
return rowHeaderList.maxOf {
it.shortName.getTextWidth(16f, 10f)
}
}
fun String.getTextWidth(textSize: Float, extraWidth: Float): Int {
val paint = Paint()
paint.textSize = textSize
val systemScale = resources.configuration.fontScale
val density = resources.displayMetrics.density
return ((paint.measureText(this) + extraWidth) * systemScale * density).toInt()
}
And then set this value to TableView: updateRowHeaderWidth(getMaxWidth(rowHeaderList))
fun updateRowHeaderWidth(rowHeaderWidth: Int) {
tableView.rowHeaderWidth = rowHeaderWidth
}
@evrencoskun Frustrated that I cannot have the row header width be the largest width in my list of strings. I am getting ellipses on all my row headers since one header is much longer than the static row header dimens.
Could you please show solution for row header to be width of longest item in list.