I've a condition check to decide if the ProgressBar
should appear or not. The layout looks like below where the ProgressBar
is contained within a RelativeLayout
:
<RelativeLayout
android:id="@+id/someID"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<ProgressBar
android:id="@+id/someProgressBar"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:indeterminate="true"
/>
</RelativeLayout>
In the fragment :
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);
....
}
and I programtically try to change the visibility of the progress bar with the setVisibility()
function like:
if(someCondition)
progressBar.setVisibility(View.GONE);
else
progressBar.setVisibility(View.VISIBLE);
But the above never works. So I tried to make changes at the xml
level by adding android:visibility="gone"
which sets the initial visibility to GONE
state, but I'm again lost on how to make the ProgressBar visibile.
I appreciate your thoughts on this.
Thanks.