如何隐藏特定片段中的操作栏

时间:2016-12-16 23:39:27

标签: java android-studio

我有片段A,B,C,D。我想在片段D中隐藏操作栏。

我已经尝试了getActivity().getActionBar().hide();但它没有用。

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;


    }

}

1 个答案:

答案 0 :(得分:3)

我有同样的问题,正在寻找答案。得到了它!

在这里。希望它会有所帮助:

// 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();
相关问题