I was able to create and combine multiple views from my custom view class which extends a LinearLayout, and it worked well. I followed this Stack Overflow answer. But you have to create an XML file and inflate it to populate the custom view.
I want to do it programmatically not by using an XML layout and inflating it. Is this possible?