Padding between ActionBar's home icon and title

前端 未结 21 1544
名媛妹妹
名媛妹妹 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:34

    When you are using a custom Toolbar, you can use

    toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setTitle(R.string.activity_title);
    setSupportActionBar(toolbar);
    getSupportActionBar().setLogo(R.drawable.logo);
    

    and in your toolbar layout simply set app:titleMarginStart="16dp"

    Note that you have to set the icon as a logo, don't use getSupportActionBar().setIcon(R.drawable.logo) instead use: getSupportActionBar().setLogo(R.drawable.logo)

提交回复
热议问题