【问题标题】:Bottom app bar Navigation icon is not center vertical底部应用栏导航图标不是垂直居中
【发布时间】:2018-10-23 19:38:09
【问题描述】:

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

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

带选项菜单

没有选项菜单

谁能告诉我如何解决它?

【问题讨论】:

    标签: android android-layout material-design android-appbarlayout bottombar


    【解决方案1】:

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

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

    【讨论】:

      【解决方案2】:

      尝试不同的方法后,通过样式设置填充效果。

      <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

      【讨论】:

      • 谢谢!
      • 一定要声明新的 Material 样式。直接在我的 XML 中声明它对我有帮助,并添加了它。 style="@style/Widget.MaterialComponents.BottomAppBar"
      【解决方案3】:

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

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

      而不是:

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

      style.xml

      【讨论】:

        【解决方案4】:

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

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

        用于底部栏。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2013-11-16
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2016-09-16
          • 1970-01-01
          • 2014-12-24
          相关资源
          最近更新 更多