When deleting or adding views, linearlayout needs to measure and compose all of its children again, and that is why they move. You can simply try to set the visibility to invisible.
myLinearLayout.setVisibility(View.INVISIBLE);
any view set to invisible retains its size and layout, but can no longer be seen.
triggs
source share