title: Changing visibility of Android ProgressBar
body: <p>I've a condition check to decide if the <code>ProgressBar</code> should appear or not. The layout looks like below where the <code>ProgressBar</code> is contained within a <code>RelativeLayout</code>:</p>
  
  <pre><code>&lt;RelativeLayout
      android:id="@+id/someID"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:gravity="center"&gt;
  
      &lt;ProgressBar
          android:id="@+id/someProgressBar"
          style="?android:attr/progressBarStyleLarge"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:indeterminate="true"
          /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>In the fragment :</p>
  
  <pre><code> ProgressBar progressBar;
  
   @Override
  public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup   container,
                           @Nullable Bundle savedInstanceState) {
   View root = inflater.inflate(R.layout.some_main_layout, container, false);
   progressBar =(ProgressBar) root.findViewById(R.id.someProgressBar);
   ....
  </code></pre>
  
  <p>}</p>
  
  <p>and I programtically try to change the visibility of the progress bar with the  <code>setVisibility()</code> function like:</p>
  
  <pre><code>   if(someCondition)
         progressBar.setVisibility(View.GONE);
     else
         progressBar.setVisibility(View.VISIBLE);
  </code></pre>
  
  <p>But the above never works. So I tried to make changes at the <code>xml</code> level by adding <code>android:visibility="gone"</code> which sets the initial visibility to <code>GONE</code> state, but I'm again lost on how to make the ProgressBar visibile.</p>
  
  <p>I appreciate your thoughts on this.</p>
  
  <p>Thanks.</p>