5

我正在使用android.support.design.bottomappbar.BottomAppBar,但添加选项菜单时导航图标出现在左上角。

没有选项它按预期工作(center_vertical)。

带选项菜单

在此处输入图像描述

没有选项菜单

在此处输入图像描述

任何人都可以告诉如何解决它?

4

4 回答 4

7

在您的布局中,您可以将BottomAppBar 主题更改为:

<android.support.design.bottomappbar.BottomAppBar
    ...
    android:theme="@style/Widget.MaterialComponents.BottomAppBar"
/>
于 2018-11-21T21:11:43.740 回答
5

在尝试了不同的方法之后,通过样式设置填充是有效的。

<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>

添加样式后

于 2018-05-14T08:19:05.377 回答
2

使用 Google Material 组件时,最好使用Theme.MaterialComponents主题作为应用程序父主题:

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

代替 :

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

style.xml

于 2018-07-02T05:53:02.650 回答
0

我也遇到了同样的问题,但通过添加找到了解决方案:

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

对于底部栏。

于 2018-12-25T07:47:28.380 回答