删除操作栏上的空格

时间:2014-09-05 07:18:59

标签: android android-actionbar

我希望在转到片段时返回更改按钮菜单。 我用了这段代码:

actionBar.setIcon(R.drawable.back50);
    actionBar.setHomeButtonEnabled(true);
    actionBar.setDisplayHomeAsUpEnabled(false);

但是当跑步按钮左侧有空格时。 enter image description here

enter image description here

2 个答案:

答案 0 :(得分:0)

使用以下代码删除该空格

actionBar.setDisplayShowCustomEnabled(true);
actionBar.setDisplayShowHomeEnabled(false);

答案 1 :(得分:0)

    View homeIcon = findViewById(android.R.id.home);
        // Hides the View (and so the icon)
        if (homeIcon != null)
            ((View) homeIcon.getParent()).setVisibility(View.GONE);