我的标志不显示在动作条正确的位置 [英] My Logo doesn't display at the correct position in actionbar
本文介绍了我的标志不显示在动作条正确的位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我写这篇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);
}
}
这篇关于我的标志不显示在动作条正确的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文