我的标志不显示在动作条正确的位置

问题描述:

我写这篇code到我的活动,我的徽标显示,但它的标志前一个空格

I wrote this code into my Activity and my logo displays, but it has a space before the logo

getSupportActionBar().setDisplayUseLogoEnabled(true);
    getSupportActionBar().setDisplayShowHomeEnabled(true);
    getSupportActionBar().setIcon(R.drawable.emenu_logo);
    setTitle("");

截图:

输入图像的描述在这里

我不知道如何解决这个问题,请大家帮帮我!

I don't know how to fix that, please help me!

试试这个例子

public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    ActionBar mActionBar = getActionBar();
    mActionBar.setDisplayShowHomeEnabled(false);
    mActionBar.setDisplayShowTitleEnabled(false);
    mActionBar.setDisplayHomeAsUpEnabled(false);
    mActionBar.setDisplayUseLogoEnabled(false);
    LayoutInflater mInflater = LayoutInflater.from(this);

    View mCustomView = mInflater.inflate(R.layout.custom_actionbar, null);   // you layout file

    /// TextView,ImageView,Button  etc element 

    mActionBar.setCustomView(mCustomView);
    mActionBar.setDisplayShowCustomEnabled(true);
    mActionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);

   }

}