如何改变工具栏导航图标,然后选择菜单保证金 [英] How to change Toolbar navigation icon and options menu margin

查看:212
本文介绍了如何改变工具栏导航图标,然后选择菜单保证金的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法来改变导航图标的左边距和实施项目的工具栏右边距

Is there any way to change the left margin of the Navigation icon and the right margin of the Action items in Toolbar?

推荐答案

我经历了工具栏源$ C ​​$ C,以找到一个解决方案,它竟然是pretty的简单。

I went through the Toolbar source code to find a solution and it turned out to be pretty simple.

工具栏使用两种风格样式的工具栏和导航图标。只是要覆盖这些风格与我自己的。

Toolbar uses two styles to style the toolbar and the navigation icon. Just had to override those styles with my own.

<style name="myToolbarNavigationButtonStyle" parent="@style/Widget.AppCompat.Toolbar.Button.Navigation">
    <item name="android:minWidth">0dp</item>
    <item name="android:padding">12dp</item>
    <item name="android:scaleType">centerInside</item>
</style>

<style name="myToolbarStyle" parent="@style/Widget.AppCompat.Toolbar">
    <item name="android:paddingRight">10dp</item>
</style>

<style name="AppTheme" parent="AppBaseTheme">
    <item name="toolbarStyle">@style/myToolbarStyle</item>
    <item name="toolbarNavigationButtonStyle">@style/myToolbarNavigationButtonStyle</item>
</style>

这篇关于如何改变工具栏导航图标,然后选择菜单保证金的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆