# Prevent button layout changing after one is removed?

I have a layout with four buttons in it. I end up removing one of the buttons using:

View v = (View) findViewById(R.id.ViewId);
((ViewManager) v.getParent()).removeView(v);


The problem is, whenever I remove one button (which works fine), the other three buttons move out of place.

For example, I have a top right button, a top left button, a bottom right button, and a bottom left button. I choose to remove the top right button using the code I gave earlier. This causes all the other three buttons to move out of place.

I think this may be because of the xml, where it states things like:

android:layout_toRightOf


And I think that when I move one button, that statement in the xml has nothing to be to the right of, and so it goes of to a random position. Is there a way I can remove these statements without having to change the position of my buttons?

Can I keep the buttons independent of each-other?

View b = findViewById(R.id.your_button);