如何减少Android中actionbar应用程序徽标左侧的填充

如何减少Android中actionbar应用程序徽标左侧的填充,android,Android,我知道我可以通过创建一个带有内置填充的自定义绘图来添加填充,但如何减少这种填充(如下所示) 因为这是主页,后退按钮是隐藏的,所以空间是空的。我在想也许有一种方法可以告诉用户界面不要为后退按钮留出空间 在清单中,您可以为操作栏“主页”按钮指定备用图像 使用工具栏。您可以轻松地将图标添加到xml中 查看google开发者博客的这篇文章:你必须添加一些actionbar方法来避免这种情况 actionbar.setDisplayShowCustomEnabled(true); acti

我知道我可以通过创建一个带有内置填充的自定义绘图来添加填充,但如何减少这种填充(如下所示)

因为这是主页,后退按钮是隐藏的,所以空间是空的。我在想也许有一种方法可以告诉用户界面不要为后退按钮留出空间


在清单中,您可以为操作栏“主页”按钮指定备用图像


使用工具栏。您可以轻松地将图标添加到xml中


查看google开发者博客的这篇文章:

你必须添加一些actionbar方法来避免这种情况

actionbar.setDisplayShowCustomEnabled(true);
        actionbar.setIcon(new ColorDrawable(getResources().getColor(
                android.R.color.transparent)));
        actionbar.setDisplayShowHomeEnabled(false);
        View customView = getLayoutInflater().inflate(
                R.layout.actionbar_main, null);
        actionbar.setCustomView(customView);
        Toolbar parent = (Toolbar) customView.getParent();
        parent.setContentInsetsAbsolute(0, 0);

您使用的是工具栏还是操作栏?什么版本的app compat?嗨,奎师那-你的回答非常简洁;如果您可以添加一些关于此解决方案如何工作以及为什么工作的解释和上下文,那就更好了?
actionbar.setDisplayShowCustomEnabled(true);
        actionbar.setIcon(new ColorDrawable(getResources().getColor(
                android.R.color.transparent)));
        actionbar.setDisplayShowHomeEnabled(false);
        View customView = getLayoutInflater().inflate(
                R.layout.actionbar_main, null);
        actionbar.setCustomView(customView);
        Toolbar parent = (Toolbar) customView.getParent();
        parent.setContentInsetsAbsolute(0, 0);
Toolbar parent = (Toolbar) customView.getParent();
parent.setContentInsetsAbsolute(0,0);