Add custom layout to ActionBar with Gravity Left?

試著忘記壹切 提交于 2019-12-08 09:12:07

问题


The ActionBar shows a space on the left side of the custom view. I want to set my custom view align left of Actionbar.

I'm trying to set

    getSupportActionBar().setDisplayShowTitleEnabled(false);
    getSupportActionBar().setDisplayShowHomeEnabled(false);

and any other method like setLogo(null),But it's not work.

My code is like

    ABCMainView actionLayout = new ABCMainView(this); //my custom view
    getSupportActionBar().setDisplayShowCustomEnabled(true);
    getSupportActionBar().setDisplayShowTitleEnabled(false);
    getSupportActionBar().setDisplayShowHomeEnabled(false);
    getSupportActionBar().setCustomView(actionLayout);

My ActionBar is android-appcompat-v21.

How can i do this?


回答1:


Try with this in your Toolbar xml config

android:contentInsetStart="0dp"

Base on Chris Banes' response https://stackoverflow.com/a/26495926/1568429



来源:https://stackoverflow.com/questions/26994331/add-custom-layout-to-actionbar-with-gravity-left

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!