admin管理员组文章数量:1023056
I'm using the StaticLayout.Builder in Android, and have created a text that i want to be at the edge of the top of the canvas, however i can't seem to get rid of a margin that comes between top of canvas (y=0) and text.
I have tried simply setting y=0, and remove all kind of padding/margin i can find like:
val textPaint = TextPaint().apply { color = Color.RED; textSize = 50f; isAntiAlias = true
val metrics = fontMetrics
metrics.ascent = 0f
metrics.descent = 0f
metrics.top = 0f
}
And use "setIncludePad(false)" on the builder.
It seems that right, left and bottom don't have the padding/margin, its only on top. I have also drawn a basic "rect" using x=0 and y=0 which aligns at all 4 edges, so the canvas should be correctly set and have its edges on correct places.
Does anyone know why there is a margin over the text when using StaticLayout and setting y=0, and how to get rid of it?
I'm using the StaticLayout.Builder in Android, and have created a text that i want to be at the edge of the top of the canvas, however i can't seem to get rid of a margin that comes between top of canvas (y=0) and text.
I have tried simply setting y=0, and remove all kind of padding/margin i can find like:
val textPaint = TextPaint().apply { color = Color.RED; textSize = 50f; isAntiAlias = true
val metrics = fontMetrics
metrics.ascent = 0f
metrics.descent = 0f
metrics.top = 0f
}
And use "setIncludePad(false)" on the builder.
It seems that right, left and bottom don't have the padding/margin, its only on top. I have also drawn a basic "rect" using x=0 and y=0 which aligns at all 4 edges, so the canvas should be correctly set and have its edges on correct places.
Does anyone know why there is a margin over the text when using StaticLayout and setting y=0, and how to get rid of it?
本文标签: javaHow to align text at top edge of canvas using StaticLayoutStack Overflow
版权声明:本文标题:java - How to align text at top edge of canvas using StaticLayout? - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745564965a2156393.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论