我希望在视图顶部绘制位图图标,如下所示:
我尝试了answer类似的问题,但它对我不起作用
override fun onDraw(canvas: Canvas) {
super.onDraw(canvas)
if (checkIconBitmap != null) {
canvas.drawBitmap(checkIconBitmap,
canvas.width - centerPosition.toFloat(),
canvas.height - centerPosition.toFloat(),
paint)
}
}
答案 0 :(得分:-1)
可能是因为您使用的是Swift代码?覆盖乐趣不是实际的Android代码。看起来应该更像这样:
@Override
protected void onDraw(canvas Canvas) {
super.onDraw(canvas)
if (checkIconBitmap != null) {
canvas.drawBitmap(checkIconBitmap,
canvas.width - centerPosition.toFloat(),
canvas.height - centerPosition.toFloat(),
paint)
}
}