- I draw this rectangle
- I move to the left with controller in center. So webview in leftside was smaller than previous.
But My DrawingView wasn't smaller. <- That is problem.
xml
<FrameLayout>
<WebView /> <- contents
<DrawingView /> <- My Custom Drawing View ( onDraw )
</FrameLayout>
When FrameLayout's size changed DrawingView Can't change size.
How to do??
My DrawingView : ViewGroup()
private val pathList = emptyList()
override fun onTouchEvent(event: MotionEvent?): Boolean {
MotionEvent.ACTION_MOVE -> {
pathList.last().offsetList.add(touchX to touchY)
invalidate()
return true
}
}
// save to pathList
override fun onDraw(canvas: Canvas) {
pathList.forEach {
canvas.draw()
}
}
//draw canvas with pathList
I tried
var ratioX = 1f
override fun onSizeChanged(w: Int, h: Int, ow: Int, oh: Int) {
ratioX = w.toFloat() / 2560
super.onSizeChanged(w, h, ow, oh)
}
override fun onDraw(canvas: Canvas) {
pathList.forEach{
canvas.drawPath(it * ratioX) // only X
}
}
but this solution drawing miss ( out of point in drawing )

