How to add a button on the canvas in android from the activity class. I am not using any layout xml here. Any sort of code will be helpful.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You will make a container (a layout object) where you will add your button. A button is a
Viewobject so it cannot be added to acanvas.On the
canvasyou can only draw static images and graphics and you won’t interact with them by default like you do with a button.I also recommend you to define the layout in the XML. It is a really good practice and helps you separate the layers of your application (presentation, controller, engine)