I have an existing xml layout and i am loading this layout in my activity class. Now i want to draw a rectangle in this at bottom.Which on clicking would call new intent.How do i add this rectangle to my existing layout.
public void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.chart);
this the code to draw the graphics.. How do i achieve this?
drawView = new DrawView(this);
drawView.setBackgroundColor(Color.WHITE);
setContentView(drawView);
Activities have nothing to do with drawing UI (in any case they never do this directly). View classes are responsible for drawing.
In your case you probably should extend
Buttonclass with your custom class. OverrideonMeasure()to make it square. And background will be anything you set it to be.A quick example:
SquareButton.java:Layout that uses this button
main.xml:Screenshot of result:
