向左添加自定义布局到ActionBar? [英] Add custom layout to ActionBar with Gravity Left?
本文介绍了向左添加自定义布局到ActionBar?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
ActionBar在自定义视图的左侧显示一个空格. 我想将自定义视图设置为在操作栏的左侧对齐.
The ActionBar shows a space on the left side of the custom view. I want to set my custom view align left of Actionbar.
我正在尝试设置
getSupportActionBar().setDisplayShowTitleEnabled(false);
getSupportActionBar().setDisplayShowHomeEnabled(false);
以及其他任何方法,例如setLogo(null),但这是行不通的.
and any other method like setLogo(null),But it's not work.
我的代码就像
ABCMainView actionLayout = new ABCMainView(this); //my custom view
getSupportActionBar().setDisplayShowCustomEnabled(true);
getSupportActionBar().setDisplayShowTitleEnabled(false);
getSupportActionBar().setDisplayShowHomeEnabled(false);
getSupportActionBar().setCustomView(actionLayout);
我的ActionBar是android-appcompat-v21.
My ActionBar is android-appcompat-v21.
我该怎么做?
推荐答案
在您的工具栏xml配置中尝试使用此方法
Try with this in your Toolbar xml config
android:contentInsetStart="0dp"
基于Chris Banes的回复 https://stackoverflow.com/a/26495926/1568429
Base on Chris Banes' response https://stackoverflow.com/a/26495926/1568429
这篇关于向左添加自定义布局到ActionBar?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文