【发布时间】:2019-07-13 06:00:15
【问题描述】:
我正在尝试使用阴影文本创建自定义视图。
如您所见,阴影超出了圆圈。我希望阴影在圆圈内。
圆圈是视图的背景。我从 xml 设置的
android:background="@drawable/background"
这是我的 onDraw 方法
override fun onDraw(canvas: Canvas) {
paint.color = shadowColor
for (shadow in shadowList) {
canvas.drawText(text, width / 2 - textBound.width() / 2 + shadow.dx, height / 2 + textBound.height() / 2 + shadow.dy, paint)
}
paint.color = textColor
canvas.drawText(text, (width / 2 - textBound.width() / 2).toFloat(), (height / 2 + textBound.height() / 2).toFloat(), paint)
}
我想要实现的是圆圈内的阴影。
【问题讨论】:
标签: android android-layout android-view android-custom-view android-shape