I have 3 fragments in my activity and I want to make one fragment full screen by hiding the status bar. When I exit that fragment, the status bar should reappear. How can I do that?
Its always better to define a function in your parent activity which will have the code to hide the status bar and calling that in your target fragment will hide the status bar for that fragment and when you are exiting the fragment in its stop method you can show the status bar again.
Let this be your method in activity,
public void hideStatusBar()
{
// your code depending upon what you have implemented
}
public void showStatusBar()
{
// your code depending upon what you have implemented
}
and then on fragment resume you can call this method like this,
((ParentActivity)getActivity()).hideStatusBar();
and to show it again for other fragment you can override the onStop of fragment,
((ParentActivity)getActivity()).showStatusBar();
Visit https://developer.android.com/training/system-ui/status.html and https://developer.android.com/training/system-ui/visibility.html
clearly explained how to hide and show statusbar in different android versions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With