Changing the ActionBar hide animation?

前端 未结 5 1370
滥情空心
滥情空心 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:25

    Neither of solutions doesn't work for me so I try this to disable animation at all:

    public void setActionBarVisible(boolean isVisible) {
        View decorView = getWindow().getDecorView();
        int resId;
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB
            || Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            resId = getResources().getIdentifier(
                    "action_bar_container", "id", getPackageName());
        } else {
            resId = Resources.getSystem().getIdentifier(
                    "action_bar_container", "id", "android");
        }
        if (resId != 0) {
            decorView.findViewById(resId).setVisibility(isVisible ? View.VISIBLE : View.GONE);
        }
    }
    

    And it works just fine for me. You can try to animate whole action bar viewGroup to achieve similar effect.

提交回复
热议问题