如何在小于 48dp 的工具栏上垂直居中菜单项?

How to vertically center menu item on toolbar less than 48dp?

我想在我的 30dp 高度工具栏上将一个简单的菜单项垂直居中。我意识到 Material 指南建议使用 48dp 的工具栏,但我的屏幕上有太多项目,无法放弃任何不动产。必须有一种方法可以使我的工具栏中的菜单项垂直居中??

菜单 Inflation:

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    getMenuInflater().inflate(R.menu.menu_main, menu);
    return true;
}

Menu_main.xml:

<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto">
    <item
        android:title="Function"
        android:id="@+id/menu_func_keys"
        app:showAsAction="always" />
</menu>

这是我看到的:

我知道有点晚了,但如果有帮助...

在另一个线程中找到了答案:

基本上 Android 根据工具栏中的 minHeight 参数使菜单项居中。所以设置为:

<android.support.v7.widget.Toolbar
    android:minHeight="Whatever your toolbar height is">
</android.support.v7.widget.Toolbar>

菜单项现在应该居中!