为什么setCustomView总是在左边和右边留下一点空间


actionBar = getSupportActionBar();
ActionBar.LayoutParams params = new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
View view = LayoutInflater.from(this).inflate(R.layout.head, null);
actionBar.setCustomView(view, params);

,

我尝试了很多方法搜索,但失败了。

试着删除边距:

ActionBar actionBar = getSupportActionBar();
actionBar.setDisplayShowHomeEnabled(false);
actionBar.setDisplayShowCustomEnabled(true);
actionBar.setDisplayShowTitleEnabled(false);
View customView = getLayoutInflater().inflate(R.layout.main_action_bar, null);
actionBar.setCustomView(customView);
Toolbar parent =(Toolbar) customView.getParent();
parent.setContentInsetsAbsolute(0,0);

最新更新