1

I add a Button and TextView in my program,

which I set them on the same row.

Then I try to add a canvas on the second row,

However it somehow cover my button and TextView on the first row.

Here's my code from MainActivity.java, onCreate() method:

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    setTitle("DotSmasher");
    canvas = new DotSmasherCanvas(getBaseContext());
    //some other codes here


    //Toggle button
    toggleButton = (ToggleButton) findViewById (R.id.toggleButton);
    toggleButton.setText("Stop");
    toggleButton.setOnCheckedChangeListener(this);


    layout = (RelativeLayout) findViewById(R.id.layout);
    layout.addView(canvas);
    layout.setPadding(0,0,0,0);

    textSec = (TextView)findViewById(R.id.textSec);
    //Rest of codes here

This is my activity_main.xml:

This is my activity_main.xml

I want to add canvas below those two items (Button and TextView).

How should I do that?

  • A canvas is not a type of view in Android. Are you saying you want to create a custom view that you can draw into? – Doug Stevenson Mar 05 '16 at 20:47
  • Yes. I am still new to programming, what I am trying to do is: http://stackoverflow.com/questions/7048103/android-drawing-button-to-canvas-with-custom-view The first solution from this link. I want those 2 elements to be outside of canvas – user2789240 Mar 05 '16 at 20:50

0 Answers0