Nothing is being drawn, even tho function is called.
I tried:
1. Moving super.onDraw(canvas) to beginning and end of onDraw
2. Replacing it with draw(canvas)
3. Creating my view dynamically and statically (I mean, in XML)
4. Adding setWillNotDraw(false)
class GameView(context: Context) : View(context) {
init {
setWillNotDraw(false) // doesn't change anything
setBackgroundColor( Color.DKGRAY ) // this actually works, but onDraw is not, why?
}
private val ballPaint = Paint(ANTI_ALIAS_FLAG).apply {
color = 0xfefefe
style = Paint.Style.FILL
}
override fun onDraw(canvas: Canvas?) {
println("Test") // printed!
canvas!!.apply {
drawCircle((width/2).toFloat(), (height/2).toFloat(), 100.0f, ballPaint )
}
super.onDraw(canvas)
}
}
What am I doing wrong?
Thanks to pskink, that was the problem
color = 0xfffefefe.toInt()