android - 如何使用带有垂直居中菜单导航和操作的扩展高度工具栏?

标签 android android-toolbar

我想要一个非标准高度的工具栏,它具有居中的按钮和导航,但我无法让它工作。我使用这个示例布局:

<Toolbar
    android:id="@+id/toolbar_regular"
    android:background="#777"
    android:layout_width="300dp"
    android:layout_height="100dp" />

最后看起来像这样:

Extended Height Toolbar With Uncentered Buttons

最佳答案

根据 conversation on G+ with Chris Banes ,您可以使用 minHeight 来定义操作和按钮的约束高度。此值默认为工具栏上的 ?attr/actionBarSize。所以,我使用了布局

<Toolbar
    android:id="@+id/toolbar_regular"
    android:background="#777"
    android:minHeight="100dp"
    android:layout_width="300dp"
    android:layout_height="100dp" />

得到这个外观:

Extended Height Toolbar With Uncentered Buttons

关于android - 如何使用带有垂直居中菜单导航和操作的扩展高度工具栏?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26494058/

相关文章:

Android:切换到 ListActivity 时无法设置 ContentView

Android:如何/教程将 ActionBar 更改为 ActionBarCompat(工具栏)?

android - 在WebViewClient的某个页面隐藏工具栏向上按钮

android - 设计工具栏和使用 float 操作按钮

Android 工具栏不从 Backstack 上的 fragment 调用 onOptionsItemSelected

android - 如何检查用户是否触摸了什么?

java - 我可以以编程方式打开/关闭对讲吗?

android - 尝试将 fragment 覆盖在现有布局上

Android 如何在 Canvas onDraw 方法中创建 onClick 事件

android - Eclipse Juno,永无止境的 Android 工具包更新