I would like to know if it possible to use and draw a view such as a TextView or Chronometer inside my custom View which uses the canvas to perform drawing.
My goal is to reuse the Chonometer view from Android inside my custom view and drawing it above all my canvas layers.
I searched like for the whole day, android sources, 3rd party libs but can't figure out.
Also I noticed that on View class there is no way to set bounds or positionning or something so I might not be able to do what I want.
Any help would be greatly appreciated! :)
Thanks.
Something like:
class CustomView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
) : View(context, attrs, defStyleAttr) {
private val chronometer: Chronometer = Chronometer(context)
override fun onDraw(canvas: Canvas) {
//Here I perform all my others drawing
//Does not work
chronometer.draw(canvas)
}
}
Copyright Notice:Content Author:「Clyx Hidden」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/74492926/can-we-use-and-draw-view-inside-custom-view-using-canvas-on-android