【发布时间】:2018-08-25 04:13:16
【问题描述】:
我有以下代码将一些文本放在图像的顶部:
val paint = TextPaint(Paint.ANTI_ALIAS_FLAG)
paint.color = Color.WHITE
paint.textSize = 40f //* context.resources.displayMetrics.density
paint.typeface = Typeface.DEFAULT_BOLD
//paint.textAlign = Paint.Align.
paint.setShadowLayer(1f, 0f, 1f, Color.DKGRAY)
val teststr = "Hello World Hello World Hello World Hello World"
val canvas = Canvas(bitmap)
val textLayout = StaticLayout(teststr, paint, canvas.width ,Layout.Alignment.ALIGN_CENTER, 1f, 0f, false)
textLayout.draw(canvas)
但是,实际上,我希望文本位于图像的底部。如何将StaticLayout 与Bitmap 的底部对齐,使文本出现在图像的底部。
【问题讨论】:
-
Canvas#translate
标签: android text bitmap android-bitmap staticlayout