setViewVisibility set visibility of the specified view. But if the view is ProgressBar, you can't set its visibility with this method, otherwise, an exception will be threw out; to resolve this issue, you can add an extra a layout, such as FrameLayoout/LinearLayout, outside ProgressBar, and then set vitiblity of the outside layout. ...> .../>