How to hide action bar for fragment?

前端 未结 9 1182
挽巷
挽巷 2021-01-31 08:17

How can I hide action bar for certain fragment? I have searched for the answer at stackoverflow, but I have only found a solution, which involves disabling action bar for main a

相关标签:
9条回答
  • 2021-01-31 09:04

    Have you tried getActivity().getSupportActionBar().hide() in the onCreate() of the fragment you wish the ActionBar to be hidden in?

    I am assuming you are not using ActionBarSherlock.

    0 讨论(0)
  • 2021-01-31 09:06

    You can simply put this into your Fragment Class createView method:-

        View layout = inflater.inflate(R.layout.player_fragment, container, false);
        ((AppCompatActivity) getActivity()).getSupportActionBar().hide();
    
    0 讨论(0)
  • 2021-01-31 09:09

    Hide actionBar using this in the required fragment.

    getActivity().getSupportActionBar().hide();
    

    And Show actionBar with this in your next fragment.

    getActivity().getActionBar().show();
    
    0 讨论(0)
提交回复
热议问题