简体   繁体   中英

how to hide action bar in a specific fragment

I have Fragment A , B , C , D . I Want to hide action bar in fragment D .

I have tried getActivity().getActionBar().hide(); and it did not work.

public class Profile extends Fragment {

    public Profile() {
        // Required empty public constructor
    }

    public static Profile newInstance(int instance) {
        Bundle args = new Bundle();
        args.putInt("argsInstance", instance);
        Profile profile = new Profile();
        profile.setArguments(args);
        return profile;
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {

        getActivity().getActionBar().hide();


        // Inflate the layout for this fragment
        View profile = inflater.inflate(R.layout.fragment_profile, container, false);

        return profile;


    }

}

I had the same question and was searching for the answer. and got it!

Here it is. hope it will help:

// Hide the status bar.
int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;
view.setSystemUiVisibility(uiOptions);
// Remember that you should never show the action bar if the
// status bar is hidden, so hide that too if necessary.
((AppCompatActivity)getActivity()).getSupportActionBar().hide();

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM