如何添加动作条的图标,上行按钮之间的填充/保证金? [英] How to add padding/margin between icon and Up-Button of the ActionBar?

查看:108
本文介绍了如何添加动作条的图标,上行按钮之间的填充/保证金?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要的向上按钮和图标,在默认的操作栏图标和标题之间的5个DP设置10dp保证金(安卓4.2.2),任何人都可以请建议如何可以做到的。

I have to set margin of 10dp between up button and icon, 5 dp between icon and Title in default action bar (android 4.2.2), can anyone please suggest how it can be done.

我不希望创建自定义的操作栏是我需要的是完全一样的变革高度默认操作栏和图标之间进行填充,向上按钮和标题。在文字大小也随之变化。

I don't want to create custom action bar as my required is exactly same as default action bar with change in height, and padding between icon, up button and title. Also change in text size.

可以这样使用defualt操作栏来实现。我能够改变操作栏的高度。

Can this be achieved using defualt action bar. I am able to change the height of action bar.

推荐答案

您可以通过从该动作条的图标ImageView的添加填充/保证金

You can add a padding / margin by getting the ImageView of the icon from the ActionBar.

这是如何:

ImageView icon = (ImageView) findViewById(android.R.id.home);
FrameLayout.LayoutParams iconLp = (FrameLayout.LayoutParams) icon.getLayoutParams();
iconLp.topMargin = iconLp.bottomMargin = 0;
icon.setLayoutParams(iconLp);

编辑:使用此code例如在活动的的onCreate 方法

Use this code for example in your Activity's onCreate method.

这篇关于如何添加动作条的图标,上行按钮之间的填充/保证金?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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