I'm trying to hide the activity toolbar inside a fragment when it is attached to the screen. And restore the toolbar when the fragment is detached.
How can I achieve this in a smooth way?
In your fragment you can do it by
@Override
public void onResume() {
super.onResume();
((AppCompatActivity)getActivity()).getSupportActionBar().hide();
//Replace AppCompateActivity with the activity class you used.
}
@Override
public void onDetach(){
super.onDetach();
((AppCompatActivity)getActivity()).getSupportActionBar().show();
//Replace AppCompateActivity with the activity class you used.
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.