Padding between ActionBar's home icon and title

前端 未结 21 1644
名媛妹妹
名媛妹妹 2020-11-28 20:03

Does anybody know how to set padding between the ActionBar\'s home icon and the title?

21条回答
  •  一向
    一向 (楼主)
    2020-11-28 20:46

    This is a common question in Material Design as you may want to line your toolbars title with the content in the fragment below. To do this, you can override the default padding of "12dp" by using the attribute contentInsetStart="72dp" in your toolbar.xml layout as shown below

    toolbar.xml

    
    
    

    Then in your activity, call

    Toolbar toolbar = (Toolbar) activity.findViewById(R.id.toolbar);
    toolbar.setTitle("Title Goes Here");
    

    And you end up with this:

提交回复
热议问题