@Nullable public static Toolbar getSupportActionBarView(@Nullable ActionBar ab) { if (ab == null || !(ab instanceof WindowDecorActionBar)) return null; try { WindowDecorActionBar decorAb = (WindowDecorActionBar) ab; Field field = WindowDecorActionBar.class.getDeclaredField("mDecorToolbar"); field.setAccessible(true); ToolbarWidgetWrapper wrapper = (ToolbarWidgetWrapper) field.get(decorAb); field = ToolbarWidgetWrapper.class.getDeclaredField("mToolbar"); field.setAccessible(true); return (Toolbar) field.get(wrapper); } catch (Throwable t) { throw new RuntimeException("Failed to retrieve Toolbar from AppCompat support ActionBar: " + t.getMessage(), t); } }