android hide toolbar in specific fragment

前端 未结 9 1271
既然无缘
既然无缘 2021-01-31 08:20

I have a problem that I don\'t know how to solve. How do you hide a toolbar in a specific fragment, I have already been searching around on the internet and what I found was com

9条回答
  •  难免孤独
    2021-01-31 08:55

    In the fragment's onCreate method call:
    ((AppCompatActivity) getActivity()).getSupportActionBar().hide();
    Replace AppCompateActivity with the activity class you used.

    Edited:

    You could simply use the onResume method to call hide() and the onStop method to call show() as suggested in some of the comments.

    @Override
    public void onResume() {
        super.onResume();
        ((AppCompatActivity)getActivity()).getSupportActionBar().hide();
    }
    
    @Override
    public void onStop() {
        super.onStop();
        ((AppCompatActivity)getActivity()).getSupportActionBar().show();
    }
    

提交回复
热议问题