【问题标题】:Android ActionBar Backbutton Default PaddingAndroid ActionBar 后退按钮默认填充
【发布时间】:2016-04-10 14:47:54
【问题描述】:

我正在创建一个自定义ActionBar,使用RelativeLayout 和左侧的ImageButton替换它。我已经从 google 的网站下载了返回图标,以便在 ImageButton 上使用

问题是我需要创建一个返回按钮来替换原来ActionBar的返回按钮,并且我需要它与原来ActionBar的返回按钮完全相同。

我想知道系统对后退按钮图像的默认填充是什么?

【问题讨论】:

    标签: android android-layout android-actionbar android-toolbar


    【解决方案1】:

    您需要在声明中添加如下几行:

    app:contentInsetLeft="0dp"
    app:contentInsetStart="0dp"
    app:contentInsetStartWithNavigation="0dp"
    

    您可以通过调整上述数据来调整间距。

    例子:

    <android.support.v7.widget.Toolbar
      xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      android:id="@+id/toolbar"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:minHeight="?attr/actionBarSize"
      android:theme="@style/ToolbarTheme"
      app:titleTextAppearance="@style/Toolbar.TitleText"
      app:titleTextColor="@android:color/white"
      app:contentInsetLeft="0dp"
      app:contentInsetStart="0dp"
      app:contentInsetStartWithNavigation="0dp"
      app:popupTheme="@style/ThemeOverlay.AppCompat.Light">
    

    【讨论】:

      【解决方案2】:

      嗯,我认为 contentInset 的默认值是 16 dp (left & right)

      更多信息:(搜索内嵌的内容)https://android.googlesource.com/platform/frameworks/base/+/refs/heads/master/core/res/res/values/dimens_material.xml

      Android API 21 Toolbar Padding

      我希望这能回答你的问题。

      【讨论】:

        【解决方案3】:

        Material Design spec 开始,工具栏图标的内边距为 16dp。

        请参阅“应用栏图标顶部、底部、左侧内边距:16dp”

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2012-04-23
          • 1970-01-01
          • 2016-08-03
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多