2014-09-05 65 views
0

我想要更改按钮菜单时返回一个片段。 我用这个代码:删除操作栏上的空格

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

但运行按钮时,必须在左空间。 enter image description here

enter image description here

+0

你在那里通过透明图像的空白 – 2014-09-05 07:28:30

回答

0

使用下面的代码,以消除空间

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

我尝试,但它不正常: HTTP://起来.ssc.vn/images/722er3.png – 2014-09-05 08:12:43

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

欢迎来到stackoverflow!尽管此代码块可能会回答您应该尝试通过添加相关说明来改进您的答案的问题,请参阅http://stackoverflow.com/help/how-to-answer – SMR 2015-03-05 07:46:15