Android ActionBar Backbutton默认填充
问题描述:
我正在创建自定义ActionBar
使用RelativeLayout
与ImageButton
到左边取代它。我从谷歌的网站上下载返回图标上ImageButton
Android ActionBar Backbutton默认填充
问题用的是我需要创建一个返回按钮代替原来的ActionBar
的后退按钮,我需要的是完全相同的原ActionBar
的后退按钮。
我想知道什么是系统的Back按钮图像的默认填充?
答
嗯,我想contentInset的默认值是16 DP(左&右)
欲了解更多信息:(搜索此内容的插图)https://android.googlesource.com/platform/frameworks/base/+/refs/heads/master/core/res/res/values/dimens_material.xml
Android API 21 Toolbar Padding
我希望这回答你的问题。
答
你需要在声明如下添加下面几行:
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">
感谢您的帮助 – JayVDiyk