简体   繁体   中英

Bottom app bar Navigation icon is not center vertical

I'm using android.support.design.bottomappbar.BottomAppBar but the navigation icon is coming in left top corner when option menu is added.

without Option its working as expected (center_vertical).

With option menu

在此处输入图片说明

Without Option Menu

在此处输入图片说明

Can any one tell how to fix it?

In your layout, you can change the BottomAppBar theme to this:

<android.support.design.bottomappbar.BottomAppBar
    ...
    android:theme="@style/Widget.MaterialComponents.BottomAppBar"
/>

After trying different ways, setting padding through styles worked.

<style name="NavButtonPadding" parent="@android:style/Widget.ActionButton">
    <item name="android:paddingStart">10dp</item>
    <item name="android:paddingEnd">10dp</item>
    <item name="android:minWidth">10dp</item>
</style>

After Adding styles

It's better to use Theme.MaterialComponents themes as application parent theme when you use Google Material components:

<style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">

instead of :

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">

in style.xml

I have also got the same issue, but found a solution by adding:

style="@style/Widget.MaterialComponents.BottomAppBar"

for bottomBar.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM