Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove ActionBar in fragment

I have some troubles trying to remove a toolbar in a specific fragment, i have this code in onCreateView fragment method:

    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_login,container,false);
    mValidator = new Validator(this);
    mValidator.setValidationListener(this);
    mFbHelper = new 
    mGHelper = new GoogleHelper(this, null, this);

    ((DrawerUtil) getActivity()).setDrawerLocked(true);
    ((AppCompatActivity) getActivity()).getSupportActionBar().hide();
    initViews(view);
    return view;
}

I can hide the ActionBar, but the idea is to remove the ActionBar to use properly a logo, im using this code: ((AppCompatActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(state); but it doesnt work.enter image description here Any ideas?

like image 326
Johan Sánchez Avatar asked Nov 02 '25 04:11

Johan Sánchez


1 Answers

For a specific fragment you can use :

override fun onStart() {
        super.onStart()
        (activity as AppCompatActivity).supportActionBar!!.hide()
    }

    override fun onStop() {
        super.onStop()
        (activity as AppCompatActivity).supportActionBar!!.show()
    }


    override fun onResume() {
        super.onResume()
        (activity as AppCompatActivity).supportActionBar!!.hide()
    }
like image 145
Yogesh Nikam Patil Avatar answered Nov 04 '25 20:11

Yogesh Nikam Patil