I have a class named SeatsPanel where I draw seats (using drawRect) in the onDraw method. The onDraw method uses Canvas as a parameter, but how do you set size of the Canvas? The reason why I’m asking this question is because this class is being inflated in another class. I know that the canvas has the default height and width of the phone, but I need to make it smaller. How can I do this?
Any help would be appreciated.
I’ve tried to implement a simple application that draws a black rect within the main activity, that is drawn pushing a button. For example, in the
MainActivity:And in the
YourViewclass:The main.xml: