'How to programmatically delete a seekbar in android studio

I am trying to write a program in which I am deleting the seekbar if the seekbar is set to zero. So far, I have been able to remove the visibility of the seekbar from the android screen, but it is not deleted completely. Can anyone please hep me so that I can completely remove the seekbar when the position of the seekbar is set to zero. Following is my code snippet:

 sb.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
            @Override
            public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
                if(i==0)
                {
                    sb.setVisibility(View.INVISIBLE);
                }
            }

            @Override
            public void onStartTrackingTouch(SeekBar seekBar) {

            }

            @Override
            public void onStopTrackingTouch(SeekBar seekBar) {

            }
        });


Solution 1:[1]

You can use sb.setVisibility(View.GONE);

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Tushar Shetty