【发布时间】:2018-10-23 19:38:09
【问题描述】:
我正在使用 android.support.design.bottomappbar.BottomAppBar,但添加选项菜单时导航图标出现在左上角。
没有选项它按预期工作(center_vertical)。
带选项菜单
没有选项菜单
谁能告诉我如何解决它?
【问题讨论】:
标签: android android-layout material-design android-appbarlayout bottombar
我正在使用 android.support.design.bottomappbar.BottomAppBar,但添加选项菜单时导航图标出现在左上角。
没有选项它按预期工作(center_vertical)。
带选项菜单
没有选项菜单
谁能告诉我如何解决它?
【问题讨论】:
标签: android android-layout material-design android-appbarlayout bottombar
在您的布局中,您可以将 BottomAppBar 主题更改为:
<android.support.design.bottomappbar.BottomAppBar
...
android:theme="@style/Widget.MaterialComponents.BottomAppBar"
/>
【讨论】:
尝试不同的方法后,通过样式设置填充效果。
<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>
【讨论】:
在使用 Google Material 组件时,最好使用 Theme.MaterialComponents 主题作为应用父主题:
<style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
而不是:
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
在style.xml
【讨论】:
我也遇到了同样的问题,但是通过添加找到了解决方案:
style="@style/Widget.MaterialComponents.BottomAppBar"
用于底部栏。
【讨论】: