Changing the ActionBar hide animation?

前端 未结 5 1377
滥情空心
滥情空心 2021-02-01 18:09

By default in Android 3.0+, when ActionBar.hide()/show() are called the bar is animated with a brief fade in/out animation.

There does not seem to be an XML style attri

5条回答
  •  不知归路
    2021-02-01 18:23

    Yes, you most certainly can.

    You first get the ActionBar view like this:

    public View getActionBarView() {
        Window window = getActivity().getWindow();
        View v = window.getDecorView();
        int resId = getResources().getIdentifier("action_bar_container", "id", "android");
        return v.findViewById(resId);
    }
    

    Then you can apply animations directly on the view like this:

    View actionbar = getActionBarView();
    actionbar.setTranslation(-48); // move it out of the screen
    

提交回复
热议问题