How to set space on left&right of the logo in the actionBar ?

自闭症网瘾萝莉.ら 提交于 2019-12-04 20:03:22

How can I minimize/set the space on the left&right of the logo ?

Use these attributes in your toolbar to handle margins of the toolbar view.

        android:layout_marginLeft="-16dp"
        app:titleMarginStart="@dimen/your_required_space"

-16dpleaves about 4dp space.

The disadvantage of using layout_marginLeft is that it does not work well when there is another view before the logo or your custom bitmap. For example, hamburger icon in case of Navigation Drawer, up-caret icon (back-arrow) when child activity is launched or navigation drawer is opened. This happens because the logo gets replaced by such views.

In such case, you can use :

        app:contentInsetStartWithNavigation="0dp"

Why does it occur?

Maybe, toolbar class uses already set dimensions which the developers think are the standard dimensions and there is no explicit way to alter them.

Should I just use a custom view instead?

You can use custom views as you've complete control but with custom views, you get custom headaches.

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