【问题标题】:Android Toolbar has more padding than ActionBar, how to fixAndroid Toolbar 的 padding 比 ActionBar 多,如何解决
【发布时间】:2015-04-12 09:36:19
【问题描述】:

我不得不更换操作栏来实现设计团队想要的新 UI 模式

actionbar 现在被 ToolBar 替换了,但是工具栏对象比 actionbar 大,只是稍微大一点,但它很明显并且不需要

这是 XML 声明

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/toolbar"
    android:layout_height="?attr/actionBarSize"
    android:layout_width="match_parent"
    android:minHeight="?attr/actionBarSize"
    android:background="?attr/colorPrimary" />

如何让它变小?我曾经能够依赖actionBarSize,它已经为每个屏幕尺寸预定义,我可以输入一个特定的 dp 值,但这是这个对象的解决方案吗?

谢谢

【问题讨论】:

  • 您确定它不仅仅是因为 Material 主题有更大的操作栏吗?这是从非实体操作栏移动时的预期变化。
  • @ianhanniballake 我不确定,所以我的应用程序使用父主题 Theme.AppCompat.Light.NoActionBar 并且我的 appcompant 依赖项是 v7 version 21+ ,所以我想这是可能的,我该如何修复高度虽然?
  • 那么您的意思是,使用 AppCompat 版本 21 ActionBarActivityTheme.AppCompat.Light 为您提供的操作栏与 Theme.AppCompat.Light.NoActionBar 中的工具栏高度不同,而其他一切都相同?
  • @ianhanniballake 是的,工具栏对象比操作栏对象占据更大的高度,即使工具栏的高度设置为?attr/actionBarSize

标签: android android-actionbar material-design android-toolbar


【解决方案1】:

?attr/actionBarSize 是 56dp,带有新的支持库。因此,即使您坚持使用操作栏,您也会获得更大的尺寸。在您的主题中设置 actionBarSize。

【讨论】:

    猜你喜欢
    • 2016-03-14
    • 1970-01-01
    • 2016-09-16
    • 1970-01-01
    • 2015-04-04
    • 2015-03-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多