简体   繁体   English

如何在操作栏中添加填充并增加导航抽屉图标的宽度?

[英]How to add padding and increase width of Navigation Drawer icon in Action bar?

I want to increase width of Navigation drawer icon and add left and right padding to it. 我想增加导航抽屉图标的宽度,并向其添加左右填充。 Any idea how to do it? 知道怎么做吗?

Thanks 谢谢

For padding you can use: 对于填充,您可以使用:

ImageView view = (ImageView)findViewById(android.R.id.home);
view.setPadding(left, top, right, bottom);

Regarding the Icon width have you tried using a larger icon? 关于图标宽度,您是否尝试过使用较大的图标?

I also wanted the icon to be wider, so I used Gimp (image editor) to make it wider (just added a few more pixels of the grey lines and extra transparency to the right). 我还希望该图标更宽,因此我使用Gimp(图像编辑器)使其更宽(只是在右侧添加了更多像素的灰线和额外的透明度)。 The Action Bar displays the icon appropriately and moves the other elements over to fit (like the action bar title). 动作栏会适当显示图标,然后将其他元素移到合适的位置(例如动作栏标题)。 I've provided the image below in case you want to use it: 如果您想使用它,我提供了以下图片: ic_drawer.png宽

You can do it using the styles: 您可以使用以下样式进行操作:

 <style name="DrawerArrowStyle" parent="Widget.AppCompat.DrawerArrowToggle">
    <item name="spinBars">true</item>
    <item name="color">#FE1B56</item>
    <item name="barSize">20dp</item>
    <!--<item name="thickness">3dp</item>-->
</style>

Add this in your parent theme 将此添加到您的父主题中

 <item name="drawerArrowStyle">@style/DrawerArrowStyle</item>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM