Changing the ActionBar hide animation?

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

    A hack for disabling the ActionBar animation (found by inspecting the source code) can be done through introspection via:

    try
    {
      getActionBar().getClass().getDeclaredMethod("setShowHideAnimationEnabled", boolean.class).invoke(getActionBar(), false);
    }
    catch (Exception exception)
    {
      // Too bad, the animation will be run ;(
    }
    

    Ugly, of course, but this actually work, at least from Android v4.2.

提交回复
热议问题